@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --brand:      #EFBF00;
  --brand-dark: #C9A000;
  --brand-light:#FFF8D6;
  --sidebar:    #111827;
  --sidebar-hover: #1f2937;
  --bg:         #F5F6FA;
  --card:       #FFFFFF;
  --border:     #E5E7EB;
  --text:       #111827;
  --text-2:     #6B7280;
  --text-3:     #9CA3AF;
  --radius:     12px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: width .2s;
}

.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo .logo-mark {
  background: var(--brand);
  color: #111;
  font-weight: 700;
  font-size: 15px;
  padding: 6px 12px;
  border-radius: 8px;
  letter-spacing: -.3px;
  display: inline-block;
}

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

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
  padding: 12px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  border-radius: 8px;
  margin: 1px 8px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--brand); color: #111; font-weight: 600; }
.nav-item svg { flex-shrink: 0; width: 16px; height: 16px; }

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

.main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
}
.breadcrumb a { color: var(--text-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { color: var(--text-3); }
.breadcrumb .current { color: var(--text); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #111;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
}

.page { padding: 24px; flex: 1; }

.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { color: var(--text-2); margin-top: 2px; font-size: 13px; }

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; }

/* ── Stats row ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-sub   { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.stat-icon  { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  background: #FAFAFA;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAFA; }
.table-link { color: var(--text); font-weight: 500; text-decoration: none; }
.table-link:hover { color: var(--brand-dark); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-gray   { background: #F3F4F6; color: #374151; }
.badge-yellow { background: #FEF3C7; color: #92400E; }
.badge-blue   { background: #DBEAFE; color: #1E40AF; }
.badge-orange { background: #FED7AA; color: #92400E; }
.badge-green  { background: #D1FAE5; color: #065F46; }
.badge-red    { background: #FEE2E2; color: #991B1B; }
.badge-dark   { background: #E5E7EB; color: #374151; }
.badge-brand  { background: var(--brand); color: #111; }

/* ── SLA indicator ── */
.sla-ok      { color: #059669; }
.sla-en_riesgo { color: #D97706; }
.sla-critico  { color: #DC2626; }
.sla-vencido  { color: #7F1D1D; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, box-shadow .15s;
  text-decoration: none;
}
.btn:hover { opacity: .9; }
.btn-primary { background: var(--brand); color: #111; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-danger   { background: #FEE2E2; color: #991B1B; }
.btn-ghost    { background: transparent; color: var(--text-2); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
label { font-size: 13px; font-weight: 500; color: var(--text); display: block; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(239,191,0,.15);
}
textarea { resize: vertical; min-height: 100px; }
.input-error { border-color: #EF4444; }
.error-msg { color: #EF4444; font-size: 12px; margin-top: 4px; }

/* ── Filters bar ── */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  transition: all .15s;
}
.filter-tab.active, .filter-tab:hover {
  background: var(--brand);
  color: #111;
  border-color: var(--brand);
}

/* ── Ticket thread ── */
.thread { display: flex; flex-direction: column; gap: 16px; }

.message {
  display: flex;
  gap: 12px;
}
.message.mine { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand); color: #111;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.msg-avatar.agente { background: var(--sidebar); color: #fff; }

.msg-bubble {
  max-width: 72%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.message.mine .msg-bubble { background: var(--brand-light); border-color: #F0D060; }
.msg-nota { background: #FFFBEB; border: 1px dashed #FCD34D; }

.msg-meta {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.msg-author { font-weight: 600; color: var(--text-2); }
.msg-content { color: var(--text); line-height: 1.6; white-space: pre-wrap; }

/* ── Stepper ── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 90px;
  position: relative;
}
.step::before {
  content: '';
  position: absolute;
  top: 13px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step:last-child::before { display: none; }
.step-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--border); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  z-index: 1; position: relative;
  border: 2px solid var(--border);
}
.step.done .step-dot  { background: var(--brand); border-color: var(--brand); color: #111; }
.step.done::before    { background: var(--brand); }
.step.active .step-dot{ background: var(--brand); border-color: var(--brand); color: #111; box-shadow: 0 0 0 4px rgba(239,191,0,.25); }
.step-label { font-size: 10.5px; font-weight: 500; color: var(--text-3); text-align: center; }
.step.done .step-label, .step.active .step-label { color: var(--text); }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  width: 100%;
  max-width: 420px;
}
.login-header {
  background: var(--sidebar);
  padding: 32px;
  text-align: center;
}
.login-body { padding: 32px; }
.login-logo { font-size: 20px; font-weight: 700; background: var(--brand); color: #111; padding: 8px 20px; border-radius: 10px; display: inline-block; }
.login-title { color: rgba(255,255,255,.9); font-size: 18px; margin-top: 16px; }
.login-sub   { color: rgba(255,255,255,.5); font-size: 13px; margin-top: 4px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  transform: translateY(16px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 700; }

/* ── Toast ── */
.toast-wrap {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 300;
}
.toast {
  background: var(--sidebar);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 4px solid var(--brand); }
.toast.error   { border-left: 4px solid #EF4444; }

@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Misc ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--text-2); }
.text-sm    { font-size: 12.5px; }
.flex       { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty-state svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 12px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .sidebar { width: 100%; height: 56px; flex-direction: row; min-height: unset; }
  .main { margin-left: 0; margin-top: 56px; }
  .grid-2 { grid-template-columns: 1fr; }
}
