/* assets/css/app.css */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Space+Mono:wght@400;700&display=swap');

/* ============================================================
   CSS VARIABLES — LIGHT & DARK
   ============================================================ */
:root {
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'Space Mono', monospace;

  /* Brand */
  --cap-blue:   #0070f3;
  --cap-light:  #e8f1ff;
  --eri-green:  #00b04f;
  --eri-light:  #e6f7ee;

  /* Surface */
  --bg-body:    #f4f6fb;
  --bg-card:    #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;
  --text-sidebar:   #cbd5e1;
  --text-sidebar-active: #ffffff;

  /* Border */
  --border:         #e2e8f0;
  --border-focus:   #0070f3;

  /* Status colors */
  --status-open:       #3b82f6;
  --status-progress:   #f59e0b;
  --status-waiting:    #8b5cf6;
  --status-resolved:   #10b981;
  --status-closed:     #6b7280;

  /* Priority */
  --prio-low:      #10b981;
  --prio-medium:   #3b82f6;
  --prio-high:     #f59e0b;
  --prio-critical: #ef4444;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.12);

  /* Transitions */
  --transition: 0.2s ease;

  /* Sidebar */
  --sidebar-w: 260px;
}

[data-theme="dark"] {
  --bg-body:        #0d1117;
  --bg-card:        #161b22;
  --bg-sidebar:     #010409;
  --bg-sidebar-hover: #1c2128;
  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #6e7681;   /* brighter than before so it's readable as placeholder */
  --border:         #30363d;   /* slightly lighter — was too dark, borders invisible */
  --cap-light:      #0d2340;
  --eri-light:      #0a2318;
  /* Dark-only extras */
  --cap-blue-dark-text: #60a5fa;   /* lighter blue for text on dark surfaces */
  --eri-green-dark-text: #4ade80;
  --bg-input:       #0d1117;   /* inputs slightly darker than card */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.6);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--cap-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  transition: transform var(--transition);
}

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

.sidebar-brand .brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--cap-blue);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.brand-version {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.brand-logo-img {
  height: 40px;
  width: auto;
  display: block;
}

.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--cap-blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-avatar.ericsson { background: var(--eri-green); }

.user-info { overflow: hidden; }
.user-name  { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 11px; color: var(--text-muted); }

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

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-sidebar);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(0,112,243,.15);
  color: #fff;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--cap-blue);
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--prio-critical); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }

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

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

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

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);        /* explicit — never inherit an invisible colour */
  background: var(--bg-card);        /* own background so dark mode applies cleanly */
}

.card-body { padding: 20px; }

/* STAT CARDS */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
}

.stat-card.blue::before   { background: var(--status-open); }
.stat-card.yellow::before { background: var(--status-progress); }
.stat-card.green::before  { background: var(--status-resolved); }
.stat-card.red::before    { background: var(--prio-critical); }
.stat-card.purple::before { background: var(--status-waiting); }

.stat-value { font-size: 32px; font-weight: 700; line-height: 1.1; letter-spacing: -1px; color: var(--text-primary); }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }
.stat-icon  { font-size: 28px; opacity: .12; position: absolute; right: 16px; top: 16px; }
.stat-change { font-size: 12px; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.stat-change.up   { color: var(--status-resolved); }
.stat-change.down { color: var(--prio-critical); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: .2px;
}

.company-badge { font-family: var(--font-mono); font-size: 10px; }
.company-cap   { background: var(--cap-light); color: var(--cap-blue); }
.company-eri   { background: var(--eri-light); color: var(--eri-green); }

/* In dark mode, badge tint backgrounds are very dark so text needs to be brighter */
[data-theme="dark"] .company-cap { color: #60a5fa; }
[data-theme="dark"] .company-eri { color: #4ade80; }

/* Priority badges */
.badge-priority-low      { background: rgba(16,185,129,.12); color: #059669; }
.badge-priority-medium   { background: rgba(59,130,246,.12); color: #2563eb; }
.badge-priority-high     { background: rgba(245,158,11,.12); color: #d97706; }
.badge-priority-critical { background: rgba(239,68,68,.12);  color: #dc2626; }

[data-theme="dark"] .badge-priority-low      { background: rgba(16,185,129,.18); color: #34d399; }
[data-theme="dark"] .badge-priority-medium   { background: rgba(59,130,246,.18); color: #60a5fa; }
[data-theme="dark"] .badge-priority-high     { background: rgba(245,158,11,.18); color: #fbbf24; }
[data-theme="dark"] .badge-priority-critical { background: rgba(239,68,68,.18);  color: #f87171; }

/* Status badges */
.badge-status-open        { background: rgba(59,130,246,.12); color: #2563eb; }
.badge-status-in-progress { background: rgba(245,158,11,.12); color: #d97706; }
.badge-status-waiting     { background: rgba(139,92,246,.12); color: #7c3aed; }
.badge-status-resolved    { background: rgba(16,185,129,.12); color: #059669; }
.badge-status-closed      { background: rgba(107,114,128,.12);color: #4b5563; }

[data-theme="dark"] .badge-status-open        { background: rgba(59,130,246,.18); color: #60a5fa; }
[data-theme="dark"] .badge-status-in-progress { background: rgba(245,158,11,.18); color: #fbbf24; }
[data-theme="dark"] .badge-status-waiting     { background: rgba(139,92,246,.18); color: #a78bfa; }
[data-theme="dark"] .badge-status-resolved    { background: rgba(16,185,129,.18); color: #34d399; }
[data-theme="dark"] .badge-status-closed      { background: rgba(107,114,128,.18);color: #9ca3af; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-primary);
}

.table thead th {
  background: var(--bg-body);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  border-top: none;
  white-space: nowrap;
}

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

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover { background: var(--bg-body); }

[data-theme="dark"] .table thead th  { background: rgba(255,255,255,.03); }
[data-theme="dark"] .table tbody tr:hover { background: rgba(255,255,255,.03); }

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

/* Select arrow — visible in both modes */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

/* Placeholder — readable in dark */
.form-control::placeholder { color: var(--text-muted); opacity: 1; }
.form-control::-webkit-input-placeholder { color: var(--text-muted); }
.form-control::-moz-placeholder           { color: var(--text-muted); }

.form-control:focus, .form-select:focus {
  background: var(--bg-card);
  border-color: var(--border-focus);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(0,112,243,.12);
  outline: none;
}

/* Dark mode overrides */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: #0d1117;
  border-color: var(--border);
  color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background: #0d1117;
  border-color: var(--border-focus);
}

/* Autofill fix */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-card) inset;
  -webkit-text-fill-color: var(--text-primary);
}

[data-theme="dark"] .form-control:-webkit-autofill,
[data-theme="dark"] .form-control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #0d1117 inset;
  -webkit-text-fill-color: var(--text-primary);
}

.form-label { font-weight: 600; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; display: block; }

.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

textarea.form-control { resize: vertical; min-height: 120px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 8px;
  padding: 8px 16px;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary   { background: var(--cap-blue); color: #fff; border-color: var(--cap-blue); }
.btn-primary:hover { background: #0060d3; color: #fff; text-decoration: none; }

.btn-success   { background: var(--eri-green); color: #fff; border-color: var(--eri-green); }
.btn-success:hover { background: #009a44; color: #fff; text-decoration: none; }

.btn-danger    { background: var(--prio-critical); color: #fff; border-color: var(--prio-critical); }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-outline-secondary {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline-secondary:hover {
  background: var(--bg-body);
  color: var(--text-primary);
  border-color: var(--text-muted);
  text-decoration: none;
}

/* Dark mode: ensure outline buttons are clearly visible */
[data-theme="dark"] .btn-outline-secondary {
  background: rgba(255,255,255,.04);
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme="dark"] .btn-outline-secondary:hover {
  background: rgba(255,255,255,.08);
  color: var(--text-primary);
  border-color: #6e7681;
}

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* ============================================================
   ALERTS & TOASTS
   ============================================================ */
.alert {
  border-radius: 10px;
  border: none;
  padding: 12px 16px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; }

/* ============================================================
   TICKET DETAIL
   ============================================================ */
.ticket-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.ticket-number {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: .5px;
}

.ticket-subject {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.3px;
  margin: 8px 0;
}

.meta-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.ticket-description {
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-top: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.7;
  font-size: 14px;
}

[data-theme="dark"] .ticket-description { background: rgba(255,255,255,.02); }

/* COMMENTS THREAD */
.comment-thread { display: flex; flex-direction: column; gap: 12px; }

.comment-item {
  display: flex;
  gap: 12px;
}

.comment-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--cap-blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}
.comment-avatar.ericsson { background: var(--eri-green); }

.comment-bubble {
  flex: 1;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}

[data-theme="dark"] .comment-bubble { background: rgba(255,255,255,.03); }

.comment-bubble.internal {
  border-color: #f59e0b;
  background: rgba(245,158,11,.05);
}

.comment-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.comment-author { font-weight: 600; font-size: 13px; }
.comment-time   { font-size: 11px; color: var(--text-muted); }
.comment-body   { font-size: 14px; line-height: 1.6; color: var(--text-primary); }

/* HISTORY TIMELINE */
.history-timeline { position: relative; }
.history-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  position: relative;
}
.history-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cap-blue);
  margin-top: 6px;
  flex-shrink: 0;
}
.history-text { font-size: 13px; color: var(--text-secondary); }
.history-time { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-split {
  display: flex;
  max-width: 900px;
  width: 100%;
  min-height: 560px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.login-panel {
  background: var(--bg-sidebar);
  width: 340px;
  flex-shrink: 0;
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-form-panel {
  background: var(--bg-card);
  flex: 1;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-panel-title { font-size: 26px; font-weight: 700; color: #fff; letter-spacing: -0.5px; line-height: 1.3; }
.login-panel-sub   { font-size: 13px; color: var(--text-sidebar); margin-top: 8px; }
.login-panel-logos { display: flex; align-items: center; gap: 12px; }
.login-panel-logo  { font-size: 12px; font-weight: 700; font-family: var(--font-mono); padding: 6px 12px; border-radius: 8px; }
.logo-cap { background: rgba(0,112,243,.2); color: #60a5fa; border: 1px solid rgba(0,112,243,.3); }
.logo-eri { background: rgba(0,176,79,.2);  color: #4ade80; border: 1px solid rgba(0,176,79,.3); }
.logo-sep { color: var(--text-muted); font-size: 16px; }

.login-form-title { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.login-form-sub   { font-size: 13px; color: var(--text-secondary); margin-bottom: 28px; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-wrapper { display: flex; align-items: center; justify-content: between; gap: 8px; padding: 16px 0 0; }

.page-link {
  min-width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.page-link:hover { border-color: var(--cap-blue); color: var(--cap-blue); }
.page-link.active { background: var(--cap-blue); border-color: var(--cap-blue); color: #fff; }
.page-link.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ============================================================
   UPLOAD AREA
   ============================================================ */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--cap-blue);
  background: rgba(0,112,243,.04);
}
.upload-area input[type="file"] { display: none; }
.upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-text { font-size: 13px; color: var(--text-secondary); }
.file-list   { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip   { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-body); border: 1px solid var(--border); border-radius: 20px; padding: 4px 10px; font-size: 12px; }
.file-chip-preview { cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s; }
.file-chip-preview:hover { background: var(--cap-blue); border-color: var(--cap-blue); color: #fff !important; box-shadow: 0 2px 8px rgba(0,112,243,.3); }
.file-chip-preview:hover span { color: rgba(255,255,255,.75) !important; }

/* ============================================================
   ESCALATION
   ============================================================ */
.escalated-banner {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--prio-critical);
  font-size: 13.5px;
}

/* ============================================================
   DARK MODE TOGGLE
   ============================================================ */
.theme-toggle {
  width: 44px; height: 24px;
  /* Light mode: slate-coloured track so it's visible on the white topbar */
  background: #94a3b8;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  flex-shrink: 0;
  outline: none;
}

/* The sliding thumb */
.theme-toggle::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 18px; height: 18px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);  /* subtle lift so thumb is crisp */
}

/* Dark mode: blue track, thumb shifted right */
[data-theme="dark"] .theme-toggle { background: var(--cap-blue); }
[data-theme="dark"] .theme-toggle::after { transform: translateX(20px); }

/* ============================================================
   NOTIFICATION BELL
   ============================================================ */
.notif-btn {
  position: relative;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.notif-btn:hover { border-color: var(--cap-blue); color: var(--cap-blue); background: var(--bg-body); }

[data-theme="dark"] .notif-btn { background: rgba(255,255,255,.04); }
[data-theme="dark"] .notif-btn:hover { background: rgba(255,255,255,.08); }

.notif-count {
  position: absolute; top: -6px; right: -6px;
  background: var(--prio-critical);
  color: #fff;
  font-size: 9px; font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-card);
}
.notif-count:empty { display: none; }

/* DROPDOWN */
.notif-dropdown {
  position: absolute;
  top: 44px; right: 0;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  display: none;
}
.notif-dropdown.show { display: block; }

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-body); }
.notif-item.unread { background: rgba(0,112,243,.06); }

[data-theme="dark"] .notif-item.unread { background: rgba(0,112,243,.1); }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  display: flex; align-items: center;
  background: var(--bg-body);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  gap: 8px;
  height: 36px;
  min-width: 240px;
  transition: border-color var(--transition);
}

.search-bar:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0,112,243,.1);
}

.search-bar input {
  border: none;
  background: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  flex: 1;
  width: 100%;
}

.search-bar input::placeholder          { color: var(--text-muted); opacity: 1; }
.search-bar input::-webkit-input-placeholder { color: var(--text-muted); }
.search-bar input::-moz-placeholder         { color: var(--text-muted); }
.search-bar .search-icon { color: var(--text-muted); font-size: 14px; }

[data-theme="dark"] .search-bar { background: #0d1117; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  transition: background var(--transition);
}

/* Topbar extra dark-mode contrast */
[data-theme="dark"] .topbar {
  background: var(--bg-card);
  border-bottom-color: var(--border);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  color: var(--text-primary);
}

/* ============================================================
   SIDEBAR MOBILE
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.show { display: block; }

  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }

  .login-split { flex-direction: column; }
  .login-panel { width: 100%; min-height: auto; padding: 28px 24px; }
  .login-form-panel { padding: 28px 24px; }

  .stat-value { font-size: 24px; }
  .ticket-subject { font-size: 18px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted-small { font-size: 12px; color: var(--text-muted); }
.text-mono { font-family: var(--font-mono); }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.rotate-icon { transition: transform var(--transition); }
.rotate-icon.open { transform: rotate(180deg); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   DARK MODE — COMPONENT PATCHES
   All components whose background or text isn't covered
   by CSS variables alone need an explicit dark override.
   ============================================================ */

/* Comment bubbles */
[data-theme="dark"] .comment-bubble { background: rgba(255,255,255,.04); border-color: var(--border); }
[data-theme="dark"] .comment-author { color: var(--text-primary); }
[data-theme="dark"] .comment-body   { color: var(--text-primary); }

/* File chips */
[data-theme="dark"] .file-chip { background: rgba(255,255,255,.05); border-color: var(--border); color: var(--text-primary); }

/* Upload area */
[data-theme="dark"] .upload-area { border-color: var(--border); }
[data-theme="dark"] .upload-area:hover { background: rgba(0,112,243,.08); }

/* Pagination */
[data-theme="dark"] .page-link { background: rgba(255,255,255,.04); border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] .page-link:hover { border-color: var(--cap-blue); color: var(--cap-blue); background: rgba(0,112,243,.1); }

/* Bootstrap modal overrides for dark */
[data-theme="dark"] .modal-content { background: var(--bg-card); border-color: var(--border); color: var(--text-primary); }
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--border); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* Bootstrap alert overrides */
[data-theme="dark"] .alert-danger  { background: rgba(239,68,68,.12); color: #f87171; border-color: rgba(239,68,68,.2); }
[data-theme="dark"] .alert-success { background: rgba(16,185,129,.12); color: #34d399; border-color: rgba(16,185,129,.2); }

/* History timeline */
[data-theme="dark"] .history-text { color: var(--text-secondary); }
[data-theme="dark"] .history-time { color: var(--text-muted); }

/* Ticket description box */
[data-theme="dark"] .ticket-description { background: rgba(255,255,255,.02); color: var(--text-primary); }

/* Table wrapper */
[data-theme="dark"] .table { color: var(--text-primary); }
[data-theme="dark"] .table thead th { color: var(--text-secondary); background: rgba(255,255,255,.03); }

/* Bootstrap bg/text utilities — override for dark */
[data-theme="dark"] .bg-light        { background: rgba(255,255,255,.06) !important; }
[data-theme="dark"] .text-dark        { color: var(--text-primary) !important; }
[data-theme="dark"] .bg-body          { background: var(--bg-body) !important; }

/* Form-text muted */
[data-theme="dark"] .form-text { color: var(--text-muted); }
[data-theme="dark"] .form-label { color: var(--text-secondary); }

/* Nav active indicator */
[data-theme="dark"] .nav-item.active { background: rgba(0,112,243,.18); }

/* Card background transition */
.card, .stat-card, .card-header, .card-body { transition: background var(--transition), border-color var(--transition), box-shadow var(--transition); }
