/* Omnitok UI Kit — tokens y componentes (Django/HTMX) */
:root {
  --ot-sidebar: #211f4b;
  --ot-primary: #4d4a9d;
  --ot-primary-dark: #3b3880;
  --ot-primary-light: rgba(77, 74, 157, 0.1);
  --ot-accent: #ff177b;
  --ot-accent-dark: #e0156e;
  --ot-accent-light: rgba(255, 23, 123, 0.1);
  --ot-success: #10b981;
  --ot-success-dark: #059669;
  --ot-success-light: rgba(16, 185, 129, 0.1);
  --ot-warning: #f59e0b;
  --ot-warning-dark: #d97706;
  --ot-warning-light: rgba(245, 158, 11, 0.1);
  --ot-error: #ef4444;
  --ot-error-dark: #dc2626;
  --ot-error-light: rgba(239, 68, 68, 0.1);
  --ot-info: #3b82f6;
  --ot-info-dark: #2563eb;
  --ot-info-light: rgba(59, 130, 246, 0.1);
  --ot-violet: #8b5cf6;
  --ot-teal: #14b8a6;
  --ot-gray-50: #f9fafb;
  --ot-gray-100: #f3f4f6;
  --ot-gray-200: #e5e7eb;
  --ot-gray-300: #d1d5db;
  --ot-gray-400: #9ca3af;
  --ot-gray-500: #6b7280;
  --ot-gray-600: #4b5563;
  --ot-gray-700: #374151;
  --ot-gray-900: #111827;
  --ot-gradient-active: linear-gradient(90deg, #ff177b 0%, #4d4a9d 100%);
  --ot-gradient-header: linear-gradient(90deg, #4d4a9d 0%, #3b3880 100%);
  --ot-font-ui: 'Nunito Sans', system-ui, sans-serif;
  --ot-font-body: 'Open Sans', system-ui, sans-serif;
  --ot-sidebar-w: 256px;
  --ot-sidebar-w-collapsed: 64px;
  --ot-header-h: 64px;
  --ot-radius: 8px;
  --ot-radius-lg: 12px;
  --ot-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.05);
}

*, *::before, *::after { box-sizing: border-box; }

body.ot-body {
  margin: 0;
  font-family: var(--ot-font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ot-gray-700);
  background: var(--ot-gray-50);
  -webkit-font-smoothing: antialiased;
}

.ot-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.ot-sidebar {
  width: var(--ot-sidebar-w);
  flex-shrink: 0;
  background: var(--ot-sidebar);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.ot-layout.sidebar-collapsed .ot-sidebar {
  width: var(--ot-sidebar-w-collapsed);
}

.ot-sidebar-brand {
  padding: 20px 16px 12px;
  text-align: center;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ot-sidebar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-family: var(--ot-font-ui);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.ot-sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--ot-gradient-active);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.ot-sidebar-system {
  margin-top: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--ot-font-ui);
}

.ot-layout.sidebar-collapsed .ot-sidebar-system,
.ot-layout.sidebar-collapsed .ot-sidebar-logo-text,
.ot-layout.sidebar-collapsed .ot-sidebar-item span {
  display: none;
}

.ot-sidebar-toggle {
  position: absolute;
  top: 12px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.8);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ot-layout.sidebar-collapsed .ot-sidebar-toggle {
  position: static;
  margin: 8px auto 0;
}

.ot-sidebar-nav {
  flex: 1;
  padding: 8px 0 12px;
  overflow-y: auto;
}

.ot-sidebar-section {
  margin: 12px 16px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.35);
  font-family: var(--ot-font-ui);
}

.ot-layout.sidebar-collapsed .ot-sidebar-section {
  display: none;
}

/* ── Dashboard ─────────────────────────────────────────────────────────────── */
.ot-dashboard-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.ot-action-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--ot-gray-200);
  border-radius: var(--ot-radius-lg);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--ot-shadow-card);
}

.ot-action-card:hover {
  border-color: var(--ot-primary);
  box-shadow: 0 4px 12px rgba(77, 74, 157, 0.12);
}

.ot-action-card-primary {
  border-color: rgba(77, 74, 157, 0.25);
  background: linear-gradient(135deg, rgba(77, 74, 157, 0.06), rgba(255, 23, 123, 0.04));
}

.ot-action-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--ot-accent-light);
  color: var(--ot-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ot-action-card-title {
  margin: 0 0 4px;
  font-family: var(--ot-font-ui);
  font-weight: 700;
  font-size: 15px;
  color: var(--ot-gray-900);
}

.ot-action-card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--ot-gray-500);
  line-height: 1.4;
}

.ot-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 960px) {
  .ot-dashboard-grid { grid-template-columns: 1fr; }
}

.ot-dashboard-panel {
  background: #fff;
  border: 1px solid var(--ot-gray-200);
  border-radius: var(--ot-radius-lg);
  overflow: hidden;
  box-shadow: var(--ot-shadow-card);
}

.ot-dashboard-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ot-gray-200);
  background: var(--ot-gray-50);
}

.ot-dashboard-panel-title {
  margin: 0;
  font-family: var(--ot-font-ui);
  font-size: 14px;
  font-weight: 700;
  color: var(--ot-gray-900);
}

.ot-mt-6 { margin-top: 24px; }

.ot-empty-sm {
  padding: 24px 16px !important;
}

.ot-empty-sm p {
  margin: 0;
  font-size: 13px;
  color: var(--ot-gray-500);
}

.ot-table-compact .ot-table td,
.ot-table-compact .ot-table th {
  padding: 8px 12px;
}

/* ── Filter tabs (jobs list) ─────────────────────────────────────────────── */
.ot-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ot-filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--ot-gray-200);
  background: #fff;
  color: var(--ot-gray-600);
  text-decoration: none;
  font-family: var(--ot-font-ui);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.ot-filter-tab:hover {
  border-color: var(--ot-primary);
  color: var(--ot-primary);
}

.ot-filter-tab.active {
  background: var(--ot-primary);
  border-color: var(--ot-primary);
  color: #fff;
}

.ot-filter-count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
}

.ot-filter-tab.active .ot-filter-count {
  background: rgba(255, 255, 255, 0.25);
}

.ot-sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 8px;
  padding: 10px 12px;
  border-radius: var(--ot-radius);
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-family: var(--ot-font-ui);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.ot-sidebar-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.ot-sidebar-item.active {
  background: var(--ot-gradient-active);
  color: #fff;
}

.ot-sidebar-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.ot-sidebar-subnav {
  display: flex;
  flex-direction: column;
  margin: 2px 8px 6px 30px;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.ot-sidebar-subitem {
  padding: 7px 10px;
  border-radius: var(--ot-radius);
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-family: var(--ot-font-ui);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.ot-sidebar-subitem:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.ot-sidebar-subitem.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.ot-layout.sidebar-collapsed .ot-sidebar-subnav {
  display: none;
}

.ot-sidebar-footer {
  padding: 12px 8px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ot-sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0;
  padding: 8px 12px;
  border-radius: var(--ot-radius);
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 13px;
}

.ot-sidebar-footer a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* ── Main area ───────────────────────────────────────────────────────────── */
.ot-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ot-header {
  height: var(--ot-header-h);
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid var(--ot-gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.ot-header-title {
  font-family: var(--ot-font-ui);
  font-size: 20px;
  font-weight: 600;
  color: var(--ot-gray-900);
  margin: 0;
}

.ot-header-subtitle {
  font-size: 13px;
  color: var(--ot-gray-500);
  margin: 2px 0 0;
}

.ot-content {
  flex: 1;
  padding: 24px;
}

/* ── Typography ──────────────────────────────────────────────────────────── */
.ot-font-ui { font-family: var(--ot-font-ui); }
.ot-h1 {
  font-family: var(--ot-font-ui);
  font-size: 24px;
  font-weight: 700;
  line-height: 32px;
  color: var(--ot-gray-900);
  margin: 0;
}
.ot-h2 {
  font-family: var(--ot-font-ui);
  font-size: 18px;
  font-weight: 600;
  line-height: 28px;
  color: var(--ot-gray-900);
  margin: 0;
}
.ot-text-muted { color: var(--ot-gray-500); }
.ot-text-sm { font-size: 13px; }
.ot-text-xs { font-size: 12px; }
.ot-mono { font-family: ui-monospace, monospace; font-size: 12px; }

/* ── Page header (CRUD pattern) ──────────────────────────────────────────── */
.ot-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.ot-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ot-gray-500);
  text-decoration: none;
  margin-bottom: 12px;
  font-family: var(--ot-font-ui);
}

.ot-breadcrumb:hover { color: var(--ot-primary); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.ot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--ot-radius);
  font-family: var(--ot-font-ui);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.ot-btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.ot-btn-primary { background: var(--ot-primary); color: #fff; }
.ot-btn-primary:hover { background: var(--ot-primary-dark); color: #fff; }
.ot-btn-accent { background: var(--ot-accent); color: #fff; }
.ot-btn-accent:hover { background: var(--ot-accent-dark); color: #fff; }
.ot-btn-neutral {
  background: #fff;
  color: var(--ot-gray-700);
  border-color: var(--ot-gray-300);
}
.ot-btn-neutral:hover { background: var(--ot-gray-50); }
.ot-btn-ghost {
  background: transparent;
  color: var(--ot-gray-600);
  border-color: transparent;
}
.ot-btn-ghost:hover { background: var(--ot-gray-100); }
.ot-btn-danger { background: var(--ot-error); color: #fff; }
.ot-btn-danger:hover { background: var(--ot-error-dark); color: #fff; }
.ot-btn-link {
  background: none;
  border: none;
  color: var(--ot-primary);
  padding: 0;
  height: auto;
  font-weight: 600;
}
.ot-btn-link:hover { color: var(--ot-primary-dark); }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.ot-card {
  background: #fff;
  border-radius: var(--ot-radius-lg);
  box-shadow: var(--ot-shadow-card);
  border: 1px solid var(--ot-gray-200);
  overflow: hidden;
}

.ot-card-header {
  background: var(--ot-gradient-header);
  color: #fff;
  padding: 12px 16px;
  font-family: var(--ot-font-ui);
  font-size: 14px;
  font-weight: 600;
}

.ot-card-body { padding: 16px; }
.ot-card-footer {
  padding: 12px 16px;
  background: var(--ot-gray-50);
  border-top: 1px solid var(--ot-gray-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.ot-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1024px) {
  .ot-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.ot-kpi {
  background: #fff;
  border: 1px solid var(--ot-gray-200);
  border-radius: var(--ot-radius-lg);
  padding: 16px;
  box-shadow: var(--ot-shadow-card);
}

.ot-kpi-value {
  font-family: var(--ot-font-ui);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ot-gray-900);
}

.ot-kpi-label {
  font-size: 12px;
  color: var(--ot-gray-500);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.ot-kpi-value.success { color: var(--ot-success); }
.ot-kpi-value.warning { color: var(--ot-warning); }
.ot-kpi-value.error { color: var(--ot-error); }
.ot-kpi-value.primary { color: var(--ot-primary); }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.ot-table-wrap {
  background: #fff;
  border-radius: var(--ot-radius-lg);
  border: 1px solid var(--ot-gray-200);
  overflow: hidden;
  box-shadow: var(--ot-shadow-card);
}

.ot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ot-table thead {
  background: var(--ot-primary);
  color: #fff;
}

.ot-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-family: var(--ot-font-ui);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ot-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ot-gray-200);
  vertical-align: middle;
}

.ot-table tbody tr:hover { background: var(--ot-gray-50); }
.ot-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.ot-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-family: var(--ot-font-ui);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
}

.ot-badge-success { background: var(--ot-success-light); color: var(--ot-success-dark); border-color: rgba(16, 185, 129, 0.25); }
.ot-badge-warning { background: var(--ot-warning-light); color: var(--ot-warning-dark); border-color: rgba(245, 158, 11, 0.25); }
.ot-badge-error { background: var(--ot-error-light); color: var(--ot-error-dark); border-color: rgba(239, 68, 68, 0.25); }
.ot-badge-info { background: var(--ot-info-light); color: var(--ot-info-dark); border-color: rgba(59, 130, 246, 0.25); }
.ot-badge-neutral { background: var(--ot-gray-100); color: var(--ot-gray-600); border-color: var(--ot-gray-200); }
.ot-badge-primary { background: var(--ot-primary-light); color: var(--ot-primary); border-color: rgba(77, 74, 157, 0.2); }
.ot-badge-accent { background: var(--ot-accent-light); color: var(--ot-accent); border-color: rgba(255, 23, 123, 0.2); }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.ot-alert {
  padding: 12px 16px;
  border-radius: var(--ot-radius);
  border: 1px solid;
  margin-bottom: 16px;
  font-size: 14px;
}

.ot-alert-warning { background: var(--ot-warning-light); border-color: rgba(245, 158, 11, 0.35); color: #92400e; }
.ot-alert-error { background: var(--ot-error-light); border-color: rgba(239, 68, 68, 0.35); color: #991b1b; }
.ot-alert-info { background: var(--ot-info-light); border-color: rgba(59, 130, 246, 0.35); color: #1e40af; }
.ot-alert-success { background: var(--ot-success-light); border-color: rgba(16, 185, 129, 0.35); color: #065f46; }

/* ── Forms / inputs ────────────────────────────────────────────────────────── */
.ot-input,
.ot-select,
.ot-textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--ot-gray-300);
  border-radius: var(--ot-radius);
  font-family: var(--ot-font-body);
  font-size: 14px;
  color: var(--ot-gray-700);
  background: #fff;
}

.ot-input:focus,
.ot-select:focus,
.ot-textarea:focus {
  outline: none;
  border-color: var(--ot-primary);
  box-shadow: 0 0 0 3px var(--ot-primary-light);
}

.ot-label {
  display: block;
  font-family: var(--ot-font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--ot-gray-600);
  margin-bottom: 6px;
}

.ot-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ot-gray-700);
  cursor: pointer;
}

/* ── Dropzone ──────────────────────────────────────────────────────────────── */
.ot-dropzone {
  border: 2px dashed var(--ot-gray-300);
  border-radius: var(--ot-radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fff;
}

.ot-dropzone:hover,
.ot-dropzone.drag-over {
  border-color: var(--ot-primary);
  background: var(--ot-primary-light);
}

/* ── Progress ──────────────────────────────────────────────────────────────── */
.ot-progress {
  height: 6px;
  background: var(--ot-gray-200);
  border-radius: 9999px;
  overflow: hidden;
}

.ot-progress-bar {
  height: 100%;
  border-radius: 9999px;
  background: var(--ot-primary);
  transition: width 0.4s ease;
}

.ot-progress-bar.success { background: var(--ot-success); }
.ot-progress-bar.error { background: var(--ot-error); }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.ot-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ot-gray-500);
}

.ot-empty h3 {
  font-family: var(--ot-font-ui);
  font-size: 18px;
  font-weight: 600;
  color: var(--ot-gray-700);
  margin: 16px 0 8px;
}

/* ── Tabs (pills) ──────────────────────────────────────────────────────────── */
.ot-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.ot-tab {
  padding: 8px 16px;
  border-radius: var(--ot-radius);
  font-family: var(--ot-font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--ot-gray-600);
  background: var(--ot-primary-light);
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.ot-tab.active {
  background: var(--ot-gradient-active);
  color: #fff;
}

.ot-hidden { display: none !important; }

/* ── Timeline / misc ───────────────────────────────────────────────────────── */
.ot-timeline-item {
  border-left: 2px solid var(--ot-gray-200);
  padding-left: 16px;
  margin-left: 8px;
  padding-bottom: 16px;
}

.ot-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--ot-primary-light);
  color: var(--ot-primary);
}

.ot-health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.ot-health-dot.ok { background: var(--ot-success); }
.ot-health-dot.warn { background: var(--ot-warning); }
.ot-health-dot.err { background: var(--ot-error); }

/* HTMX */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

.fade-in { animation: otFadeIn 0.3s ease-in; }
@keyframes otFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Utilities */
.ot-mb-4 { margin-bottom: 16px; }
.ot-mb-6 { margin-bottom: 24px; }
.ot-gap-2 { gap: 8px; }
.ot-flex { display: flex; }
.ot-flex-between { display: flex; align-items: center; justify-content: space-between; }
.ot-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.ot-max-w-3xl { max-width: 48rem; margin-left: auto; margin-right: auto; }
