/* ============================================================
   HELPDESK PRO - Estilos globales modernos
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── VARIABLES ─────────────────────────────────────────────────
   Paleta: Stitch "Enterprise Precision" — navy sobrio, fondos fríos
   ───────────────────────────────────────────────────────────────── */
:root {
  --primary:       #1e3a8a;   /* navy — botones, ítems activos, enlaces */
  --primary-dark:  #00236f;   /* navy profundo — hover de primario */
  --primary-light: #dce1ff;   /* periwinkle suave — fondos tenues */
  --secondary:     #505f76;   /* slate — apoyo, gradientes de avatar */
  --accent:        #00285e;   /* navy terciario */
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ba1a1a;   /* error de Enterprise Precision */
  --info:          #1e3a8a;

  --bg:            #f7f9fb;   /* surface */
  --bg-card:       #ffffff;   /* surface-container-lowest */
  --bg-sidebar:    #f2f4f6;   /* surface-container-low */
  --bg-header:     #ffffff;

  --text:          #191c1e;   /* on-surface */
  --text-muted:    #444651;   /* on-surface-variant */
  --text-light:    #757682;   /* outline */
  --border:        #e2e8f0;   /* outline sutil de contenedores nivel 1 */

  --sidebar-w:     260px;
  --header-h:      64px;
  --radius:        6px;       /* formas sobrias (botones, inputs) */
  --radius-lg:     10px;      /* contenedores grandes (cards, modales) */
  --shadow:        0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,.05);
  --shadow-lg:     0 10px 20px rgba(0,0,0,.08);
  --transition:    all .15s ease;
}

/* ─── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── LAYOUT  ────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: transform .3s ease;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo-img {
  width: 280px;
  height: auto;
  object-fit: contain;
  display: block;
}
.sidebar-logo .logo-text {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
}
.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-light);
  font-weight: 400;
  margin-top: 2px;
  display: block;
}
/* Bloque de marca arriba del sidebar (estilo mockup Stitch, con logo real) */
.sidebar-brand {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.sidebar-brand-logo {
  height: 40px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-bottom { padding: 12px 0 16px; }
.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
}
.nav-item {
  margin: 2px 8px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.05); color: #e2e8f0; text-decoration: none; }
/* .nav-link.active se define en la sección "NUEVO DISEÑO" (píldora navy). */
.nav-link .icon { width: 18px; text-align: center; font-size: 16px; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}
.user-name  { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.user-role  { font-size: 11px; color: #64748b; }
.user-logout {
  margin-left: auto;
  color: #475569;
  transition: color .2s;
}
.user-logout:hover { color: var(--danger); }

/* ─── MAIN CONTENT ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0; z-index: 50;
}
.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text);
}
.page-content {
  padding: 24px;
  flex: 1;
}

/* ─── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ─── STAT CARDS ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-color, var(--primary));
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-number {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat-icon {
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  font-size: 36px;
  opacity: .08;
}

/* ─── BADGES DE ESTADO ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-nuevo      { background: #d0e1fb; color: #1e3a8a; }
.badge-abierto    { background: #dce1ff; color: #00236f; }
.badge-proceso    { background: #fef3c7; color: #92400e; }
.badge-en_proceso { background: #fef3c7; color: #92400e; }
.badge-pendiente  { background: #fee2e2; color: #991b1b; }
.badge-resuelto   { background: #d1fae5; color: #065f46; }
.badge-cerrado    { background: #f1f5f9; color: #475569; }
.badge-default    { background: #f1f5f9; color: #64748b; }

/* Prioridades */
.priority-critica  { background: #fee2e2; color: #991b1b; }
.priority-alta     { background: #ffedd5; color: #9a3412; }
.priority-media    { background: #fef9c3; color: #854d0e; }
.priority-baja     { background: #dcfce7; color: #166534; }

/* ─── BOTONES ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #93000a; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

/* ─── FORMULARIOS ────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 3px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color .2s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,138,.12); }
.form-control::placeholder { color: var(--text-light); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-position: right 8px center; background-repeat: no-repeat; background-size: 16px; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 120px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ─── TABLA ───────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}
/* Tabla de datos — mismo estilo que la tabla de /admin/tickets (.tkt-tbl) */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  padding: 12px 20px;
  background: var(--bg-sidebar);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 14px 20px;
  border: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:hover { background: #f1f5f9; }
.td-ticket-num { font-weight: 700; color: var(--primary); font-size: 13px; }
.td-subject { font-weight: 500; max-width: 320px; }

/* ─── ALERTAS ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-success { background: #d1fae5; border-color: #a7f3d0; color: #065f46; }
.alert-error   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-info    { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.alert-warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }

/* ─── BÚSQUEDA & FILTROS ─────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 20px;
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.filter-bar .form-group { margin-bottom: 0; }
.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-box input { padding-left: 36px; }
.search-box .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

/* ─── PAGINACIÓN ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.page-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.page-btn:hover,
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn.disabled { opacity: .4; cursor: not-allowed; }

/* ─── CONVERSACIÓN DE TICKET ─────────────────────────────────── */
.conversation { display: flex; flex-direction: column; gap: 18px; }
.message {
  display: flex;
  gap: 14px;
  animation: fadeInUp .3s ease;
}
.message.from-agent  { flex-direction: row; }
.message.from-user   { flex-direction: row; }
.message.internal    { opacity: .85; }
.message-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
  flex-shrink: 0;
}
.message-avatar.agent { background: linear-gradient(135deg, var(--success), var(--accent)); }
.message-avatar.internal { background: linear-gradient(135deg, #f59e0b, #f97316); }
.message-bubble {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 12px 12px 12px;
  overflow: hidden;
}
.message.from-agent .message-bubble { border-top-left-radius: 0; }
.message-bubble.internal {
  background: #fffbeb;
  border-color: #fde68a;
}
.message-meta {
  padding: 10px 14px 6px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.message-author { font-weight: 700; font-size: 14px; color: var(--text); }
.message-time   { font-size: 12px; color: var(--text-muted); }
.message-internal-tag {
  font-size: 10px;
  background: #fef3c7;
  color: #92400e;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 700;
}
.message-content {
  padding: 6px 14px 14px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}
.message-attachments {
  padding: 0 14px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  transition: var(--transition);
}
.attachment-chip:hover { background: var(--primary-light); border-color: var(--primary); }

/* ─── TICKET SIDEBAR INFO ─────────────────────────────────────── */
.ticket-sidebar .info-item {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ticket-sidebar .info-item:last-child { border-bottom: none; }
.info-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.info-value { font-size: 14px; font-weight: 500; color: var(--text); }

/* ─── HOME PAGE ───────────────────────────────────────────────── */
.hero {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(37,99,235,.15) 0%, transparent 70%);
  top: -100px; left: -100px;
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(124,58,237,.1) 0%, transparent 70%);
  bottom: -50px; right: -50px;
  pointer-events: none;
}
.hero-content {
  text-align: center;
  color: #fff;
  max-width: 700px;
  position: relative;
  z-index: 1;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(37,99,235,.2);
  border: 1px solid rgba(37,99,235,.4);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #93c5fd;
  margin-bottom: 24px;
}
.hero h1 {
  font-size: 52px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fff 0%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  font-size: 18px;
  color: #94a3b8;
  margin-bottom: 36px;
  line-height: 1.8;
}
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.hero-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 60px;
}
.feature-card {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  backdrop-filter: blur(10px);
}
.feature-icon { font-size: 32px; margin-bottom: 12px; }
.feature-title { font-size: 15px; font-weight: 700; color: #e2e8f0; margin-bottom: 8px; }
.feature-desc  { font-size: 13px; color: #64748b; line-height: 1.6; }

/* ─── AUTH PAGES ─────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  background: var(--bg);
}
.auth-left {
  flex: 1;
  background: linear-gradient(135deg, #0f172a 0%, #1e40af 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  display: none;
}
.auth-right {
  width: 100%;
  max-width: 500px;
  margin: auto;
  padding: 40px 20px;
}
.auth-right .card { max-width: 440px; margin: auto; }
.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  justify-content: center;
}
.auth-logo-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff;
}
.auth-logo-img  { width: 380px; height: auto; display: block; margin: 0 auto; }
.auth-logo-text { font-size: 22px; font-weight: 800; color: var(--text); }
.auth-logo-sub  { font-size: 12px; color: var(--text-muted); display: block; }
.auth-divider   { text-align: center; color: var(--text-muted); padding: 10px 0; font-size: 13px; }

/* ─── MODALS ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 100%;
  transform: scale(.96);
  transition: transform .2s;
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 800; }
.modal-close {
  background: none; border: none; font-size: 20px;
  color: var(--text-muted); cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg); }
.modal-body    { padding: 20px 24px; }
.modal-footer  { padding: 12px 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 64px; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; margin-bottom: 20px; }

/* ─── ANIMACIONES ────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}
.animate-fade { animation: fadeInUp .4s ease; }
.loading { animation: pulse 1.5s infinite; }

/* ─── UTILITIES ──────────────────────────────────────────────── */
.d-flex    { display: flex; }
.d-grid    { display: grid; }
.gap-sm    { gap: 8px; }
.gap-md    { gap: 16px; }
.gap-lg    { gap: 24px; }
.flex-1    { flex: 1; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm  { font-size: 13px; }
.text-xs  { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.font-bold  { font-weight: 700; }
.font-mono  { font-family: 'Courier New', monospace; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.separator { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (min-width: 1024px) {
  .auth-left { display: flex; }
  .auth-right { padding: 40px; }
  .auth-right .card { max-width: 100%; }
  .auth-page { justify-content: stretch; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .menu-toggle  { display: block; }
  .topbar-title { font-size: 15px; }
  .page-content { padding: 16px; }
  .stats-grid   { grid-template-columns: repeat(2, 1fr); }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .hero h1     { font-size: 32px; }
  .hero-features { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar .form-group { width: 100%; }
}

/* ─── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── PRINT ──────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .filter-bar, .btn, .pagination { display: none !important; }
  .main-content { margin: 0; }
  .page-content { padding: 0; }
}

/* ============================================================
   NUEVO DISEÑO — SIDEBAR CLARO (surface-container-low)
   ============================================================ */
:root { --bg-sidebar: #f2f4f6; }

.sidebar {
  border-right: 1px solid var(--border);
  color: var(--text-muted);
}
.sidebar-logo {
  border-bottom: 1px solid var(--border);
}
.nav-section {
  color: #94a3b8;
}
.nav-link {
  color: var(--text-muted);
}
.nav-link:hover {
  background: rgba(0,0,0,.04);
  color: var(--text);
}
.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.nav-link.active:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.sidebar-footer {
  border-top: 1px solid var(--border);
}
.user-name  { color: var(--text); }
.user-logout { color: var(--text-muted); }

/* ============================================================
   NUEVO DISEÑO — TOPBAR
   ============================================================ */
.topbar {
  padding: 0 16px;
  gap: 12px;
}
.topbar-title { display: none; }
.topbar-actions {
  margin-left: auto;
  gap: 4px;
}

/* El logo vive en el sidebar (.sidebar-brand); las reglas de .topbar-brand
   y .topbar-logo-img se eliminaron porque ya no se usan. */

.topbar-search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  transition: border-color .2s;
}
.topbar-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,58,138,.1);
}
.topbar-search-icon {
  color: var(--text-muted);
  font-size: 15px;
  flex-shrink: 0;
}
.topbar-search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  background: transparent;
  font-family: inherit;
}
.topbar-search-input::placeholder { color: var(--text-light); }

.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 17px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  flex-shrink: 0;
  position: relative;
}
.topbar-icon-btn:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

/* Tooltip de los botones del topbar — se muestra DEBAJO del botón
   (un title nativo se posiciona solo y se salía hacia arriba del topbar) */
.topbar-icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  padding: 6px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease, visibility .15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  z-index: 200;
}
.topbar-icon-btn[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}
/* Botón pegado al borde derecho: anclamos el tooltip a la derecha para que no se salga */
.topbar-icon-btn--end[data-tooltip]::after {
  left: auto;
  right: 0;
  transform: none;
}

.topbar-vdivider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}
.topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.topbar-user-role { font-size: 11px; color: var(--text-muted); }
.topbar-user-info { display: none; }

@media (max-width: 639px) { .topbar-search { display: none; } }
@media (min-width: 640px) {
  .topbar-user-info { display: block; }
  .topbar-search    { display: flex;  }
}

/* ============================================================
   NUEVO DISEÑO — PAGE HEADER
   ============================================================ */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   NUEVO DISEÑO — STAT CARDS CON BORDE LATERAL
   ============================================================ */
.stat-card-new {
  border-left: 4px solid var(--accent-color, var(--primary));
  padding: 18px 20px;
  transition: box-shadow .2s;
}
.stat-card-new:hover {
  box-shadow: var(--shadow-md);
  transform: none;
}
.stat-card-new::before { display: none; }

.stat-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-card-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.stat-card-new .stat-number {
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}
.stat-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ============================================================
   OPERACIÓN DE SOPORTE — semáforo, SLA, avisos y tiempo real
   Añadidos de la versión "mesa de soporte": mantienen la paleta
   Enterprise Precision (navy/slate) del resto de la aplicación.
   ============================================================ */

/* Semáforo: de quién se espera el siguiente movimiento */
.wait-pill { display:inline-flex; align-items:center; gap:6px; padding:3px 10px; border-radius:20px;
             font-size:11px; font-weight:700; white-space:nowrap; }
.wait-pill .wait-dot { width:7px; height:7px; border-radius:50%; background:currentColor; flex-shrink:0; }
.wait-support     { background:#ffdad6; color:#ba1a1a; }   /* rojo: le toca a soporte */
.wait-client      { background:#fef3c7; color:#a16207; }   /* ámbar: esperando al cliente */
.wait-agent_done  { background:#dcfce7; color:#166534; }   /* verde: soporte ya respondió */
.wait-closed      { background:#f1f5f9; color:#64748b; }

/* SLA: el vencimiento lo calcula el backend, aquí sólo se presenta */
.sla-pill { display:inline-block; padding:3px 10px; border-radius:20px; font-size:11px;
            font-weight:700; white-space:nowrap; background:#f1f5f9; color:#64748b; }
.sla-ok     { background:#dcfce7; color:#166534; }
.sla-warn   { background:#fef9c3; color:#a16207; }
.sla-danger { background:#ffedd5; color:#c2410c; }
.sla-over   { background:#ffdad6; color:#ba1a1a; }

/* Avisos emergentes (toasts) */
.toast-stack { position:fixed; right:18px; bottom:18px; z-index:1200; display:flex;
               flex-direction:column; gap:10px; max-width:360px; }
.toast-item { display:flex; align-items:flex-start; gap:10px; background:var(--bg-card);
              border:1px solid var(--border); border-left:4px solid var(--primary);
              border-radius:8px; padding:12px 14px; box-shadow:var(--shadow-lg);
              animation:toastIn .25s ease; }
.toast-item.out { opacity:0; transform:translateY(6px); transition:opacity .4s, transform .4s; }
.toast-icon { color:var(--primary); font-size:16px; margin-top:1px; }
.toast-body { flex:1; min-width:0; }
.toast-title { font-size:13px; font-weight:700; color:var(--text); }
.toast-text { font-size:12px; color:var(--text-muted); margin-top:2px;
              overflow:hidden; text-overflow:ellipsis; display:-webkit-box;
              -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.toast-close { border:none; background:none; color:var(--text-light); font-size:18px;
               line-height:1; cursor:pointer; padding:0 2px; }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }

/* Campana de notificaciones del topbar */
.notif-wrap { position:relative; }
.notif-count { position:absolute; top:2px; right:2px; min-width:16px; height:16px; padding:0 4px;
               background:var(--danger); color:#fff; border-radius:9px; font-size:10px;
               font-weight:700; display:flex; align-items:center; justify-content:center; }
.notif-panel { position:absolute; top:calc(100% + 10px); right:0; width:340px; max-height:70vh;
               overflow:auto; background:var(--bg-card); border:1px solid var(--border);
               border-radius:10px; box-shadow:var(--shadow-lg); z-index:500; display:none; }
.notif-panel.open { display:block; }
.notif-head { display:flex; align-items:center; justify-content:space-between; gap:10px;
              padding:12px 14px; border-bottom:1px solid var(--border); font-size:13px;
              font-weight:700; color:var(--text); position:sticky; top:0; background:var(--bg-card); }
.notif-head-actions { display:flex; align-items:center; gap:6px; }
.notif-link { border:none; background:none; color:var(--primary); font-size:11px; font-weight:600;
              cursor:pointer; font-family:inherit; padding:2px 4px; }
.notif-list { display:flex; flex-direction:column; }
.notif-item { display:block; padding:10px 14px; border-bottom:1px solid var(--border);
              text-decoration:none; color:var(--text); }
.notif-item:hover { background:var(--bg); text-decoration:none; }
.notif-item.unread { background:var(--primary-light); }
.notif-title { font-size:13px; font-weight:600; }
.notif-body { font-size:12px; color:var(--text-muted); margin-top:2px;
              overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.notif-at { font-size:10px; color:var(--text-light); margin-top:3px; }
.notif-empty { padding:22px 14px; text-align:center; font-size:12px; color:var(--text-muted); }

/* Aviso discreto de conexión perdida con el servidor de tiempo real */
.rt-offline { position:fixed; left:50%; bottom:16px; transform:translateX(-50%); z-index:1100;
              background:#1e293b; color:#fff; font-size:12px; padding:7px 16px; border-radius:20px;
              display:flex; align-items:center; gap:7px; box-shadow:var(--shadow-lg); opacity:.92; }

/* Dashboard operativo */
.ops-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:14px; margin-bottom:16px; }
.ops-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-lg);
            padding:16px 18px; display:block; text-decoration:none; color:inherit;
            border-left:4px solid var(--primary); transition:var(--transition); }
.ops-card:hover { text-decoration:none; box-shadow:var(--shadow-md); transform:translateY(-1px); }
.ops-label { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em;
             color:var(--text-muted); display:flex; align-items:center; gap:6px; }
.ops-value { font-size:28px; font-weight:800; color:var(--text); line-height:1.2; margin-top:6px; }
.ops-sub { font-size:11px; color:var(--text-light); margin-top:2px; }
.ops-card.danger { border-left-color:var(--danger); }
.ops-card.danger .ops-value { color:var(--danger); }
.ops-card.warn { border-left-color:#d97706; }
.ops-card.warn .ops-value { color:#b45309; }
.ops-card.ok { border-left-color:#059669; }
.ops-card.ok .ops-value { color:#047857; }
.ops-two { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media (max-width:900px) { .ops-two { grid-template-columns:1fr; } }
.activity-list { display:flex; flex-direction:column; }
.activity-row { display:flex; align-items:center; gap:10px; padding:9px 20px;
                border-bottom:1px solid var(--border); font-size:13px; }
.activity-row:last-child { border-bottom:none; }
.activity-time { font-size:11px; color:var(--text-light); font-variant-numeric:tabular-nums; min-width:42px; }
.activity-who { font-weight:600; }
.activity-num { margin-left:auto; font-weight:700; color:var(--primary); font-size:12px; text-decoration:none; }
