/* ── CSS custom properties — light / dark theming ────────────────────────── */
:root {
  --bg-page:         #f8fafc;
  --bg-card:         #ffffff;
  --bg-input:        #ffffff;
  --bg-input-dis:    #f9fafb;
  --bg-table-head:   #f8fafc;
  --bg-table-hover:  #f8fafc;
  --bg-comment:      #f8fafc;
  --bg-comment-int:  #fffbeb;
  --border-card:     #e2e8f0;
  --border-input:    #d1d5db;
  --border-table:    #e2e8f0;
  --border-row:      #f1f5f9;
  --text-primary:    #1e293b;
  --text-secondary:  #64748b;
  --text-muted:      #94a3b8;
  --text-input:      #111827;
  --text-label:      #374151;
  --text-heading:    #0f172a;
}

html.dark {
  --bg-page:         #0f172a;
  --bg-card:         #1e293b;
  --bg-input:        #1e2d40;
  --bg-input-dis:    #162032;
  --bg-table-head:   #162032;
  --bg-table-hover:  #1e2d40;
  --bg-comment:      #1e293b;
  --bg-comment-int:  #2d2a14;
  --border-card:     #334155;
  --border-input:    #475569;
  --border-table:    #334155;
  --border-row:      #273549;
  --text-primary:    #e2e8f0;
  --text-secondary:  #94a3b8;
  --text-muted:      #64748b;
  --text-input:      #f1f5f9;
  --text-label:      #cbd5e1;
  --text-heading:    #f1f5f9;
}

/* ── Custom styles that complement Tailwind ─────────────────────────────── */

* { box-sizing: border-box; }

body { font-family: 'Inter', sans-serif; background: var(--bg-page); color: var(--text-primary); }

/* Sidebar nav items */
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  color: #94a3b8; cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none; margin: 1px 0;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.nav-item.active { background: rgba(59,130,246,0.18); color: #60a5fa; }
.nav-item svg { flex-shrink: 0; }

/* Stat cards */
.stat-card {
  background: var(--bg-card); border-radius: 12px; padding: 20px 24px;
  border: 1px solid var(--border-card);
}

/* Data table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 16px; text-align: left; font-size: 11px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-secondary); border-bottom: 1px solid var(--border-table);
  background: var(--bg-table-head);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border-row);
  font-size: 14px; color: var(--text-primary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover td { background: var(--bg-table-hover); }

/* Badge base */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 9999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* Status badges */
.badge-open        { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress { background: #fef3c7; color: #b45309; }
.badge-pending     { background: #ffedd5; color: #c2410c; }
.badge-resolved    { background: #dcfce7; color: #15803d; }
.badge-closed      { background: #f1f5f9; color: #475569; }

/* Priority badges */
.badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-high     { background: #ffedd5; color: #c2410c; }
.badge-medium   { background: #dbeafe; color: #1d4ed8; }
.badge-low      { background: #f0fdf4; color: #15803d; }

/* Role badges */
.badge-superadmin { background: #f3e8ff; color: #7e22ce; }
.badge-admin      { background: #ede9fe; color: #6d28d9; }
.badge-agent      { background: #dbeafe; color: #1d4ed8; }
.badge-user       { background: #f1f5f9; color: #475569; }

/* Toast animations */
@keyframes toastIn  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(110%); opacity: 0; } }
.toast     { animation: toastIn  0.3s cubic-bezier(.21,1.02,.73,1) forwards; pointer-events: all; }
.toast-out { animation: toastOut 0.25s ease forwards; }

/* Spinner */
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border-card); border-top-color: #3b82f6;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Page transition */
#page-content { animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Forms */
.form-input {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border-input); font-size: 14px;
  color: var(--text-input); outline: none;
  background: var(--bg-input);
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-input:disabled { background: var(--bg-input-dis); color: var(--text-muted); }
.form-input[readonly] { background: var(--bg-input-dis); color: var(--text-secondary); cursor: not-allowed; }

textarea.form-input { resize: vertical; min-height: 100px; }

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

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s; border: none; outline: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: #3b82f6; color: #fff; }
.btn-primary:hover:not(:disabled)  { background: #2563eb; }
.btn-success  { background: #22c55e; color: #fff; }
.btn-success:hover:not(:disabled)  { background: #16a34a; }
.btn-danger   { background: #ef4444; color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #dc2626; }
.btn-secondary {
  background: var(--bg-card); color: var(--text-label);
  border: 1px solid var(--border-input);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-table-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-table-hover); color: var(--text-primary); }

/* Card */
.card { background: var(--bg-card); border-radius: 12px; border: 1px solid var(--border-card); }

/* Priority dot indicator */
.dot-critical { background: #ef4444; }
.dot-high     { background: #f97316; }
.dot-medium   { background: #3b82f6; }
.dot-low      { background: #22c55e; }

/* Sidebar scrollbar */
#sidebar { overflow-y: auto; }
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

/* Main content scrollbar */
#main-content::-webkit-scrollbar { width: 6px; }
#main-content::-webkit-scrollbar-track { background: transparent; }
#main-content::-webkit-scrollbar-thumb { background: var(--border-input); border-radius: 4px; }

/* Comment bubble */
.comment-bubble {
  background: var(--bg-comment); border: 1px solid var(--border-card);
  border-radius: 10px; padding: 12px 16px;
}
.comment-internal { background: var(--bg-comment-int); border-color: #fde68a; }

/* Input select */
select.form-input { 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-repeat: no-repeat; background-position: right 8px center; background-size: 16px; padding-right: 32px; }

/* Mobile sidebar overlay */
#sidebar-overlay { display: none; }
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); transition: transform .25s; position: fixed !important; z-index: 30; height: 100vh !important; }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay.visible { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 29; }
}

/* ── Header dark mode ───────────────────────────────────────────────────── */
#main-content > header {
  background: var(--bg-card);
  border-color: var(--border-card);
}
#page-title { color: var(--text-primary); }

/* ── Notification dropdown ──────────────────────────────────────────────── */
#notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 50; overflow: hidden;
}
.notif-item { transition: background .1s; }
.notif-item.unread { background: rgba(59,130,246,.07); }
.notif-item:hover { background: var(--bg-table-hover) !important; }

/* ── Charts ─────────────────────────────────────────────────────────────── */
.chart-card {
  background: var(--bg-card); border-radius: 12px;
  border: 1px solid var(--border-card); padding: 20px;
}
