/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #7c3aed;
  --primary-light: #ede9fe;
  --sidebar-bg: #0f172a;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --radius: 10px;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--sidebar-bg); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--topbar-h); background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 100; }
.page-body { padding: 24px; flex: 1; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 20px 16px; font-size: 15px; font-weight: 700; color: #f1f5f9; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-nav { padding: 12px 8px; flex: 1; }
.nav-section { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #475569; padding: 12px 8px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; font-size: 13px; color: #94a3b8; text-decoration: none; margin-bottom: 2px; transition: all .15s; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .bi { font-size: 15px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,.06); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }

/* ── Cards ────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Table ────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 14px; background: #f8fafc; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }
th a { text-decoration: none; color: var(--muted); }
th a:hover { color: var(--text); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); background: #fff; outline: none; transition: border .15s; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,58,237,.1); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-select { 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; }
.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; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; border: none; cursor: pointer; text-decoration: none; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #6d28d9; }
.btn-light { background: #f1f5f9; color: var(--text); }
.btn-light:hover { background: #e2e8f0; }
.btn-danger { background: #fef2f2; color: #dc2626; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* ── Ticket Priority Row Colors ───────────────────────────── */
tr.priority-urgent td:first-child { border-left: 3px solid #dc2626; }
tr.priority-high td:first-child { border-left: 3px solid #ea580c; }
tr.priority-medium td:first-child { border-left: 3px solid #2563eb; }
tr.priority-low td:first-child { border-left: 3px solid #16a34a; }

/* ── Ticket Thread ────────────────────────────────────────── */
.message-item { padding: 16px; border-bottom: 1px solid var(--border); }
.message-item:last-child { border-bottom: none; }
.message-item.internal { background: #fffbeb; border-left: 3px solid #f59e0b; }
.message-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.message-author { font-size: 13px; font-weight: 600; }
.message-time { font-size: 11px; color: var(--muted); }
.message-body { font-size: 13px; line-height: 1.6; white-space: pre-wrap; }

/* ── SLA indicator ────────────────────────────────────────── */
.sla-ok { color: #16a34a; font-size: 11px; }
.sla-warn { color: #d97706; font-size: 11px; }
.sla-breach { color: #dc2626; font-size: 11px; font-weight: 700; }

/* ── Login page ───────────────────────────────────────────── */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); }
.login-card { background: #1e293b; border: 1px solid #334155; border-radius: 16px; padding: 40px; width: 380px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo i { font-size: 40px; color: var(--primary); }
.login-logo h1 { font-size: 20px; font-weight: 800; color: #f1f5f9; margin-top: 8px; }
.login-logo p { font-size: 13px; color: #64748b; margin-top: 4px; }
.login-card .form-label { color: #94a3b8; }
.login-card .form-control { background: #0f172a; border-color: #334155; color: #f1f5f9; }
.login-card .form-control:focus { border-color: var(--primary); }

/* ── Kanban ───────────────────────────────────────────────── */
.kanban-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kanban-col { background: #f1f5f9; border-radius: var(--radius); padding: 12px; }
.kanban-col-header { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.kanban-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; font-size: 12px; }
.kanban-card-title { font-weight: 600; margin-bottom: 6px; }

/* ── Misc ─────────────────────────────────────────────────── */
.me-1 { margin-right: 4px; }
.me-2 { margin-right: 8px; }
.text-muted { color: var(--muted); }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.row { display: grid; gap: 16px; }
.col-md-6 { min-width: 0; }
@media (min-width: 768px) { .row.g-3 { grid-template-columns: 1fr 1fr; } .row.g-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 767px) { .sidebar { display: none; } .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; } }
