/* ============================================================
   Sistema de Tickets — UI 2025
   Mobile-first · Light/Dark toggle · Minimal accent
============================================================ */

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

/* ── Variables (light default — backwards-compatible names) ── */
:root {
  /* Brand */
  --brand:          #5B17E8;
  --brand-hover:    #4910CC;
  --brand-dark:     #4A0FD0;
  --brand-light:    #f0ebff;
  --brand-dim:      rgba(91,23,232,.10);
  --brand-ring:     rgba(91,23,232,.18);
  --brand-gradient: #5B17E8;         /* alias — solid accent, no gradient */

  /* Layout */
  --sidebar-w:      240px;
  --nav-h:          56px;
  --mobile-bar-h:   60px;

  /* Surfaces — light */
  --bg:             #f4f4f7;
  --bg-hover:       #edecf2;
  --surface:        #ffffff;
  --surface-2:      #f8f8fb;
  --border:         #e5e5eb;
  --border-dark:    #ceced8;

  /* Text — light */
  --text-primary:   #0f0f14;
  --text-secondary: #52526a;
  --text-muted:     #9898aa;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05), 0 1px 4px rgba(0,0,0,.04);
  --shadow:    0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 32px rgba(0,0,0,.12);

  /* Radii */
  --radius-sm: 7px;
  --radius:    11px;
  --radius-lg: 15px;

  /* Sidebar — always dark */
  --sidebar-bg:     #0e0e12;
  --sidebar-hover:  rgba(255,255,255,.06);
  --sidebar-active: rgba(255,255,255,.13);
  --sidebar-text:   rgba(255,255,255,.80);
  --sidebar-muted:  rgba(255,255,255,.38);
}

/* ── Dark theme ───────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:             #111115;
  --bg-hover:       #18181c;
  --surface:        #19191e;
  --surface-2:      #212126;
  --border:         #29292f;
  --border-dark:    #34343c;

  --text-primary:   #ebebf0;
  --text-secondary: #8888a0;
  --text-muted:     #55555f;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow:    0 4px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 10px 32px rgba(0,0,0,.55);

  --brand-light: rgba(91,23,232,.16);
  --brand-dim:   rgba(91,23,232,.22);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--nav-h);
  min-height: 100vh;
  transition: background .2s, color .2s;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

/* ── Navbar ───────────────────────────────────────────────── */
.app-navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: .75rem;
  z-index: 1030;
  transition: background .2s, border-color .2s;
}

.app-navbar .brand {
  display: flex; align-items: center; gap: .5rem;
  text-decoration: none; white-space: nowrap;
}
.navbar-logo {
  height: 30px; width: auto; border-radius: 7px; display: block;
}
.brand-text {
  font-size: 14px; font-weight: 700;
  color: var(--text-primary);
}
.app-navbar .spacer { flex: 1; }

/* Icon buttons in navbar */
.nav-icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s;
  font-size: 15px;
  flex-shrink: 0;
}
.nav-icon-btn:hover { background: var(--bg); color: var(--text-primary); }

/* Avatar + dropdown trigger */
.nav-user { display: flex; align-items: center; gap: .5rem; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.role-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11px; font-weight: 500;
  color: var(--text-secondary);
  text-transform: capitalize;
}

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: var(--nav-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  overflow-y: auto;
  z-index: 1020;
  border-right: 1px solid rgba(255,255,255,.05);
  transition: transform .22s ease;
}
#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }

.sidebar-logo-wrap {
  padding: 1rem .875rem .5rem;
}
.sidebar-logo {
  height: 36px; width: auto; max-width: 140px;
  border-radius: 10px;
  background: rgba(255,255,255,.9);
  padding: 4px 8px; display: block;
}

.sidebar-section { padding: .375rem .75rem; }
.sidebar-section-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--sidebar-muted);
  padding: .6rem .375rem .2rem;
  display: block;
}

.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li + li { margin-top: 1px; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .55rem;
  padding: .48rem .625rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 450;
  text-decoration: none;
  transition: background .12s;
  min-height: 36px;
}
.sidebar-nav .nav-link i {
  font-size: 15px; width: 18px; text-align: center;
  opacity: .65; flex-shrink: 0;
}
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); }
.sidebar-nav .nav-link:hover i { opacity: 1; }
.sidebar-nav .nav-link.active {
  background: var(--brand);
  color: #fff; font-weight: 500;
}
.sidebar-nav .nav-link.active i { opacity: 1; }

.sidebar-count {
  margin-left: auto; flex-shrink: 0;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.65);
  border-radius: 20px;
  padding: 1px 7px;
}
.sidebar-nav .nav-link.active .sidebar-count {
  background: rgba(255,255,255,.22); color: #fff;
}

.sidebar-divider {
  border: none; border-top: 1px solid rgba(255,255,255,.07);
  margin: .5rem .75rem;
}
.sidebar-footer {
  margin-top: auto;
  padding: .75rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user-info {
  display: flex; align-items: center; gap: .5rem;
  padding: .375rem .375rem;
  border-radius: var(--radius-sm);
}
.sidebar-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.sidebar-user-name {
  font-size: 12.5px; font-weight: 500; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px; color: var(--sidebar-muted);
  text-transform: capitalize;
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1019;
  backdrop-filter: blur(2px);
}
body.sidebar-open .sidebar-overlay { display: block; }

/* ── Mobile bottom nav ────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-bar-h);
  background: var(--sidebar-bg);
  border-top: 1px solid rgba(255,255,255,.07);
  z-index: 1028;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mobile-nav-items {
  display: flex; height: 100%;
  align-items: stretch;
}
.mobile-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; padding: .4rem .25rem;
  color: rgba(255,255,255,.4);
  text-decoration: none;
  font-size: 10px; font-weight: 500;
  transition: color .15s;
  border: none; background: transparent; cursor: pointer;
}
.mobile-nav-item i { font-size: 21px; line-height: 1; }
.mobile-nav-item.active { color: var(--brand); }
.mobile-nav-item.active i { color: var(--brand); }

/* ── Main content ─────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--nav-h));
  padding: 1.5rem 1.75rem;
}

/* ── Page header ──────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-title  { font-size: 18px; font-weight: 700; color: var(--text-primary); margin: 0; }
.page-subtitle { font-size: 12.5px; color: var(--text-muted); margin: .15rem 0 0; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: background .2s, border-color .2s;
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: .8rem 1.1rem;
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
}
.card-body { padding: 1.1rem; }

/* Stat cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card .stat-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
}
.stat-card .stat-value {
  font-size: 26px; font-weight: 700;
  color: var(--text-primary); line-height: 1.2; margin: .15rem 0;
}
.stat-card .stat-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 20px;
  line-height: 1.6;
}

.badge-status-open        { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-status-in_progress { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-status-resolved    { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-status-closed      { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

.badge-priority-low    { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-priority-medium { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-priority-high   { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-priority-urgent,
.badge-priority-crucial { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.badge-publico { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-interno { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

.ticket-code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  background: var(--brand-light);
  color: var(--brand);
  padding: 2px 8px; border-radius: var(--radius-sm);
}

/* ── Tables ───────────────────────────────────────────────── */
.app-table { width: 100%; border-collapse: collapse; }
.app-table thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: .6rem .9rem;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); white-space: nowrap;
}
.app-table tbody td {
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px; vertical-align: middle;
  color: var(--text-primary);
}
.app-table tbody tr:last-child td { border-bottom: none; }
.app-table tbody tr:hover td { background: var(--bg-hover); }

/* Clickable rows */
.app-table tr.tr-link { cursor: pointer; }
.app-table tr.tr-link:hover td { background: var(--bg-hover); }

.app-table .priority-crucial td:first-child { box-shadow: inset 3px 0 0 #ef4444; }
.app-table .priority-high    td:first-child { box-shadow: inset 3px 0 0 #f97316; }
.app-table .priority-medium  td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.app-table .priority-low     td:first-child { box-shadow: inset 3px 0 0 #22c55e; }

/* ── Forms ────────────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px; padding: .5rem .75rem;
  transition: border-color .15s, box-shadow .15s, background .2s;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
  outline: none;
  background: var(--surface);
  color: var(--text-primary);
}
.form-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: .3rem; display: block;
}
.form-text { font-size: 12px; color: var(--text-muted); margin-top: .25rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  font-size: 13.5px; font-weight: 500;
  border-radius: var(--radius-sm);
  padding: .45rem 1rem; min-height: 36px;
  transition: background .15s, border-color .15s, opacity .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-hover); border-color: var(--brand-hover); color: #fff;
}
.btn-outline-secondary {
  background: transparent;
  border: 1px solid var(--border-dark);
  color: var(--text-secondary);
}
.btn-outline-secondary:hover {
  background: var(--bg); border-color: var(--border-dark); color: var(--text-primary);
}
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }

/* ── Messages / Chat ──────────────────────────────────────── */
.msg-timeline { display: flex; flex-direction: column; gap: .875rem; }

.msg-item { display: flex; gap: .625rem; align-items: flex-start; }
.msg-item.msg-self { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  background: var(--brand-light); color: var(--brand);
}
.msg-avatar.ai     { background: var(--brand); color: #fff; }
.msg-avatar.agent  { background: #dbeafe; color: #1d4ed8; }
.msg-avatar.admin  { background: #fce7f3; color: #be185d; }
.msg-avatar.client { background: #dcfce7; color: #15803d; }
.msg-avatar.slack  { background: #e0e7ff; color: #4338ca; }
.msg-item.msg-self .msg-avatar { display: none; }

.msg-bubble-wrap { flex: 1; min-width: 0; }
.msg-item.msg-self .msg-bubble-wrap { display: flex; flex-direction: column; align-items: flex-end; }

.msg-meta {
  display: flex; align-items: center; gap: .35rem;
  margin-bottom: .3rem; flex-wrap: wrap;
}
.msg-item.msg-self .msg-meta { flex-direction: row-reverse; }
.msg-author { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.msg-time   { font-size: 11px; color: var(--text-muted); }

.msg-bubble {
  display: inline-block;
  max-width: min(80%, 520px);
  padding: .625rem .9rem;
  border-radius: var(--radius-sm) var(--radius) var(--radius) var(--radius);
  font-size: 13.5px; line-height: 1.65;
  word-break: break-word; white-space: normal;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.msg-item.msg-self .msg-bubble {
  border-radius: var(--radius) var(--radius-sm) var(--radius) var(--radius);
  background: var(--brand-light);
  border-color: rgba(91,23,232,.2);
}
.msg-item.msg-ai .msg-bubble {
  background: var(--brand-light);
  border-color: rgba(91,23,232,.2);
  border-left: 3px solid var(--brand);
}
.msg-item.msg-internal .msg-bubble {
  background: #fffbeb; border-color: #fde68a;
  border-left: 3px solid #f59e0b;
}

.msg-source {
  font-size: 10px; font-weight: 500; padding: 1px 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-muted);
}

.msg-attachments { margin-top: .4rem; display: flex; flex-wrap: wrap; gap: .3rem; }
.att-pill {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: 3px 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; font-size: 12px;
  color: var(--text-secondary); text-decoration: none;
  transition: border-color .15s, color .15s;
}
.att-pill:hover { border-color: var(--brand); color: var(--brand); }

/* ── Image thumbnails en mensajes ────────────────────────── */
.msg-img-thumb {
  display: inline-block;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  margin: .25rem .25rem 0 0;
  cursor: zoom-in;
  border: 1px solid var(--border);
  transition: opacity .15s, transform .15s;
}
.msg-img-thumb:hover { opacity: .82; transform: scale(1.05); }

/* ── Lightbox ────────────────────────────────────────────── */
#img-lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: lb-fade .15s ease;
}
@keyframes lb-fade { from { opacity:0 } to { opacity:1 } }
#img-lightbox-img {
  max-width: 90vw;
  max-height: 88vh;
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 12px 60px rgba(0,0,0,.7);
  cursor: default;
  object-fit: contain;
}
#img-lightbox-close {
  position: absolute; top: 18px; right: 22px;
  background: rgba(255,255,255,.12);
  border: none; border-radius: 50%;
  color: #fff; font-size: 1.4rem;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
#img-lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ── Visibility toggle ───────────────────────────────────── */
.visibility-toggle {
  display: inline-flex;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg);
}
.visibility-toggle input[type=radio] { display: none; }
.visibility-toggle label {
  padding: .45rem .9rem; font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: background .15s, color .15s;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: .3rem;
  border-right: 1px solid var(--border);
}
.visibility-toggle label:last-of-type { border-right: none; }
.visibility-toggle input[type=radio]:checked + label {
  background: var(--surface); color: var(--text-primary);
  font-weight: 600; box-shadow: var(--shadow-sm);
}
.visibility-toggle input#vis-pub:checked + label { color: #15803d; }
.visibility-toggle input#vis-int:checked + label { color: #b45309; }

/* ── Info panel ───────────────────────────────────────────── */
.info-row {
  display: flex; padding: .45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px; align-items: flex-start; gap: .5rem;
}
.info-row:last-child { border-bottom: none; }
.info-label { width: 82px; flex-shrink: 0; color: var(--text-muted); font-size: 12px; }
.info-value { flex: 1; color: var(--text-primary); }

/* ── History ──────────────────────────────────────────────── */
.history-entry {
  display: flex; gap: .5rem; padding: .4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
  align-items: flex-start;
}
.history-entry:last-child { border-bottom: none; }
.h-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border-dark); margin-top: 5px; flex-shrink: 0;
}
.h-time { margin-left: auto; color: var(--text-muted); white-space: nowrap; padding-left: .5rem; }
.history-entry strong { color: var(--text-primary); }

/* ── Upload area ──────────────────────────────────────────── */
.upload-area {
  display: block;
  position: relative;
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--brand); background: var(--brand-light);
}
.upload-area p { font-size: 13px; color: var(--text-muted); margin: 0; }
/* El input dentro de label: oculto visualmente pero activo */
.upload-area input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
[data-theme="dark"] .upload-area:hover,
[data-theme="dark"] .upload-area.drag-over { background: rgba(91,23,232,.1); border-color: var(--brand); }

/* ── AI / escalation banners ─────────────────────────────── */
.msg-ai-banner {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem 1rem;
  background: var(--brand-light);
  border: 1px solid rgba(91,23,232,.2);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--brand); margin-bottom: 1rem;
}
.msg-ai-banner i { font-size: 15px; flex-shrink: 0; }

.escalate-btn {
  margin-left: auto; font-size: 12px; padding: 3px 12px;
  border-radius: 20px; border: 1px solid var(--brand);
  background: transparent; color: var(--brand); cursor: pointer;
  transition: background .15s, color .15s; white-space: nowrap; flex-shrink: 0;
}
.escalate-btn:hover { background: var(--brand); color: #fff; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  font-size: 13.5px; padding: .65rem 1rem;
}

/* ── Toasts ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .4rem;
}
.app-toast {
  padding: .6rem 1rem; border-radius: var(--radius-sm);
  font-size: 13px; display: flex; align-items: center; gap: .5rem;
  box-shadow: var(--shadow-lg); min-width: 220px;
  animation: slideUp .2s ease;
}
.app-toast.toast-success { background: #16a34a; color: #fff; }
.app-toast.toast-error   { background: #dc2626; color: #fff; }
@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ── DataTables ───────────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--surface); border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm); color: var(--text-primary);
  padding: .35rem .65rem; font-size: 13px;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { font-size: 12.5px; color: var(--text-muted); }
.page-item .page-link {
  background: var(--surface); border-color: var(--border);
  color: var(--text-secondary); font-size: 13px;
}
.page-item.active .page-link {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.page-item.disabled .page-link { color: var(--text-muted); background: var(--surface-2); }

/* ── Login ────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; background: var(--bg); }
.login-left {
  flex: 1; background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3rem; min-width: 0;
  border-right: 1px solid rgba(255,255,255,.06);
}
.login-right {
  width: 420px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem; background: var(--surface);
}
.login-card { width: 100%; max-width: 340px; }

@media (max-width: 576px) {
  .login-wrap { min-height: 100dvh; align-items: flex-start; }
  .login-right {
    width: 100%; min-height: 100dvh;
    align-items: flex-start;
    padding: 2.5rem 1.25rem 2rem;
  }
}

/* ── Scrollbar ────────────────────────────────────────────── */
.thin-scroll::-webkit-scrollbar { width: 4px; height: 4px; }
.thin-scroll::-webkit-scrollbar-track { background: transparent; }
.thin-scroll::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 2px; }

/* ── Ticket list ──────────────────────────────────────────── */
.tkt-list { overflow: hidden; }

.tkt-row {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-primary);
  transition: background .12s;
  position: relative;
}
.tkt-row:last-child { border-bottom: none; }
.tkt-row:hover { background: var(--bg-hover); }

/* Priority color bar */
.tkt-prio-bar {
  width: 3px;
  min-height: 40px;
  align-self: stretch;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Main body */
.tkt-body { flex: 1; min-width: 0; }

.tkt-top {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin-bottom: .3rem;
  flex-wrap: wrap;
}
.tkt-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.tkt-row:hover .tkt-subject { color: var(--brand); }

.tkt-meta {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.tkt-meta-item {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  font-size: 12px;
  color: var(--text-muted);
}

/* Right aside */
.tkt-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .3rem;
  flex-shrink: 0;
}
.tkt-unread {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--brand); color: #fff;
  border-radius: 20px; font-size: 11px; font-weight: 700;
  line-height: 1;
}
.tkt-row:has(.tkt-unread) .tkt-subject {
  font-weight: 700;
}

.tkt-msgs {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: 12px; color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 8px;
}
.tkt-time {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Mobile: stack meta under subject */
@media (max-width: 575.98px) {
  .tkt-row { gap: .6rem; padding: .75rem .875rem; }
  .tkt-subject { font-size: 13.5px; white-space: normal; }
  .tkt-aside { flex-direction: row; align-items: center; gap: .5rem; }
}

/* ── Resolution banner ────────────────────────────────────── */
.resolution-banner {
  border: 1px solid #bbf7d0; background: #f0fdf4;
  border-radius: var(--radius); padding: 1rem;
}
.resolution-banner h6 { color: #15803d; font-size: 13px; font-weight: 600; margin-bottom: .4rem; }

/* ── Dark mode adjustments ────────────────────────────────── */
[data-theme="dark"] .badge-status-open        { background: rgba(29,78,216,.15);  border-color: rgba(29,78,216,.25); }
[data-theme="dark"] .badge-status-in_progress { background: rgba(180,83,9,.15);   border-color: rgba(180,83,9,.25);  }
[data-theme="dark"] .badge-status-resolved    { background: rgba(21,128,61,.15);  border-color: rgba(21,128,61,.25); }
[data-theme="dark"] .badge-priority-low       { background: rgba(21,128,61,.15);  border-color: rgba(21,128,61,.25); }
[data-theme="dark"] .badge-priority-medium    { background: rgba(29,78,216,.15);  border-color: rgba(29,78,216,.25); }
[data-theme="dark"] .badge-priority-high      { background: rgba(194,65,12,.15);  border-color: rgba(194,65,12,.25); }
[data-theme="dark"] .badge-priority-crucial,
[data-theme="dark"] .badge-priority-urgent    { background: rgba(185,28,28,.15);  border-color: rgba(185,28,28,.25); }
[data-theme="dark"] .badge-publico            { background: rgba(21,128,61,.15);  border-color: rgba(21,128,61,.25); }
[data-theme="dark"] .badge-interno            { background: rgba(180,83,9,.15);   border-color: rgba(180,83,9,.25);  }

[data-theme="dark"] .msg-item.msg-self .msg-bubble {
  background: rgba(91,23,232,.18); border-color: rgba(91,23,232,.28);
}
[data-theme="dark"] .msg-item.msg-ai .msg-bubble {
  background: rgba(91,23,232,.14); border-color: rgba(91,23,232,.28);
}
[data-theme="dark"] .msg-item.msg-internal .msg-bubble {
  background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.2);
}

[data-theme="dark"] .resolution-banner {
  background: rgba(21,128,61,.1); border-color: rgba(21,128,61,.25);
}

[data-theme="dark"] .dropdown-menu {
  background: var(--surface-2); border-color: var(--border-dark);
}
[data-theme="dark"] .dropdown-item { color: var(--text-primary); }
[data-theme="dark"] .dropdown-item:hover { background: var(--bg); color: var(--text-primary); }
[data-theme="dark"] .dropdown-divider { border-color: var(--border); }

[data-theme="dark"] .modal-content {
  background: var(--surface); border-color: var(--border);
}
[data-theme="dark"] .modal-header { border-bottom-color: var(--border); }
[data-theme="dark"] .modal-footer { border-top-color: var(--border); }
[data-theme="dark"] .modal-body   { color: var(--text-primary); }

[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 50px var(--surface-2) inset;
  -webkit-text-fill-color: var(--text-primary);
}

[data-theme="dark"] .login-right { background: var(--surface); }

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: var(--surface-2); border-color: var(--border-dark);
}
[data-theme="dark"] textarea.form-control { background: var(--surface-2); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
  #sidebar { transform: translateX(-100%); }
  body.sidebar-open #sidebar { transform: translateX(0); }

  #main-content {
    margin-left: 0; padding: 1rem;
    padding-bottom: calc(var(--mobile-bar-h) + 1.25rem);
  }

  .mobile-nav { display: flex; }

  #toast-container {
    bottom: calc(var(--mobile-bar-h) + .75rem); right: .75rem; left: .75rem;
    align-items: flex-end;
  }

  /* Full-width bubbles on small screens */
  .msg-bubble { max-width: 88% !important; font-size: 13px; }

  /* Table horizontal scroll */
  .card .card-body.p-0 { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .app-table { min-width: 600px; }

  .page-title { font-size: 16px; }
  .card-body  { padding: .875rem; }
  .card-header { padding: .7rem .875rem; }
}

@media (max-width: 575.98px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
}
