/* ==================== VARIABLES ==================== */
:root {
  --sidebar-width: 240px;
  --primary: #1d4ed8;
  --primary-light: #dbeafe;
  --surface: #f8fafc;
  --border: #e2e8f0;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--surface);
  color: #1e293b;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ==================== LOGIN ==================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #0f3d5c 0%, #155a86 50%, #0891b2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.2);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}
.login-logo i { font-size: 1.8rem; color: #f59e0b; }

.login-subtitle {
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 24px;
}

#loginBtn {
  background: #0f3d5c;
  border-color: #0f3d5c;
}
#loginBtn:hover, #loginBtn:focus {
  background: #155a86;
  border-color: #155a86;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}
.shake { animation: shake 0.4s ease; }

/* ==================== LAYOUT ==================== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: #0f172a;
  color: #e2e8f0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 2px;
}
.logo i { font-size: 1.35rem; }
.sidebar-header small { font-size: 0.7rem; color: #64748b; padding-left: 34px; }

.sidebar-nav {
  padding: 10px 0;
  overflow-y: auto;
  flex: 1;
}
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  color: #94a3b8;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: all 0.18s;
  white-space: nowrap;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.05); color: #f1f5f9; }
.sidebar-nav .nav-link.active {
  background: rgba(59,130,246,0.15);
  color: #93c5fd;
  border-left-color: #3b82f6;
}
.sidebar-nav .nav-link i { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.68rem;
  color: #475569;
  line-height: 1.6;
}

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

/* ==================== TOPBAR ==================== */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 11px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.topbar-title { font-weight: 600; font-size: 0.95rem; color: #1e293b; flex: 1; }
.topbar-clock {
  font-family: monospace;
  font-size: 0.78rem;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 6px;
}
.topbar-user { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 0.82rem; color: #64748b; }

.role-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.role-admin   { background: #fee2e2; color: #b91c1c; }
.role-manager { background: #dbeafe; color: #1d4ed8; }
.role-staff   { background: #fef3c7; color: #92400e; }
.role-user    { background: #dcfce7; color: #15803d; }

.page-content { padding: 24px; flex: 1; }
.page-title { font-size: 1.15rem; font-weight: 700; color: #0f172a; }

/* ==================== BUTTONS ==================== */
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 7px;
  transition: background 0.15s;
}
.btn-icon:hover { background: #f1f5f9; }

.btn-icon-sm {
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 5px;
  transition: background 0.15s;
}
.btn-icon-sm:hover { background: #f1f5f9; }

/* ==================== CARDS ==================== */
.card { border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.card-header { border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0 !important; padding: 12px 20px; background: #fff !important; }
.card-body { padding: 20px; }
.card-footer { border-top: 1px solid var(--border); border-radius: 0 0 12px 12px !important; background: #fff !important; }

/* ==================== TABLES ==================== */
.table th {
  font-size: 0.73rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #64748b; white-space: nowrap;
}
.table td { vertical-align: middle; font-size: 0.85rem; }
.table-danger-light { background-color: #fff5f5 !important; }
.table-warning-light { background-color: #fffbeb !important; }
.monitoring-table th { font-size: 0.72rem; }
.monitoring-table td { font-size: 0.8rem; }

/* ==================== STATUS & SEVERITY BADGES ==================== */
.status-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.3px;
}
.badge-inservice { background: #dcfce7; color: #15803d; }
.badge-closed    { background: #f1f5f9; color: #64748b; }

.status-pill {
  display: inline-block; padding: 2px 10px;
  border-radius: 20px; font-size: 0.72rem; font-weight: 600; white-space: nowrap;
}
.status-open        { background: #dbeafe; color: #1d4ed8; }
.status-in-progress { background: #fef3c7; color: #b45309; }
.status-review      { background: #ede9fe; color: #6d28d9; }
.status-pending     { background: #f1f5f9; color: #475569; }
.status-closed      { background: #dcfce7; color: #15803d; }

.sev-badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 4px; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.sev-critical { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.sev-high     { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.sev-medium   { background: #fefce8; color: #a16207; border: 1px solid #fde68a; }
.sev-low      { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ==================== KPI CARDS ==================== */
.kpi-card {
  background: #fff; border-radius: 12px; padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); height: 100%;
  border: 1px solid var(--border);
}
.kpi-icon { font-size: 1.4rem; margin-bottom: 8px; }
.kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1; color: #0f172a; }
.kpi-label { font-size: 0.77rem; color: #64748b; margin-top: 5px; font-weight: 500; }

/* ==================== STEP BADGE ==================== */
.step-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--primary); color: #fff;
  border-radius: 50%; font-size: 0.7rem; font-weight: 700; margin-right: 8px;
}

/* ==================== UPLOAD AREA ==================== */
.upload-area {
  border: 2px dashed #cbd5e1; border-radius: 10px; padding: 32px 20px;
  text-align: center; cursor: pointer; background: #f8fafc;
  transition: all 0.2s;
}
.upload-area:hover, .upload-area.drag-over { border-color: var(--primary); background: var(--primary-light); }

/* ==================== ATTACHMENTS ==================== */
.attachment-card {
  position: relative; display: flex; align-items: center; gap: 8px;
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; max-width: 180px;
}
.attachment-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.attachment-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #dbeafe; border-radius: 6px; font-size: 1.2rem; }
.attachment-info { flex: 1; min-width: 0; }
.attachment-name { font-size: 0.72rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-size { font-size: 0.65rem; color: #94a3b8; }
.attachment-remove {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; padding: 0;
  border: none; background: #ef4444; color: #fff;
  border-radius: 50%; font-size: 0.6rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* ==================== RECENT CASES ==================== */
.recent-case-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
}
.recent-case-item:last-child { border-bottom: none; }
.recent-case-item:hover { background: #f8fafc; }

/* ==================== DETAIL CARD ==================== */
.detail-card { padding: 10px 14px; background: #f8fafc; border-radius: 8px; height: 100%; }
.detail-label { font-size: 0.7rem; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.detail-value { font-size: 0.88rem; color: #1e293b; }

/* ==================== TICKET ID DISPLAY ==================== */
.ticket-id-display {
  font-size: 1.5rem; font-weight: 700; font-family: monospace;
  background: #f0fdf4; border: 2px solid #86efac;
  color: #15803d; padding: 10px 20px; border-radius: 10px; letter-spacing: 1px;
}

/* ==================== STATUS SELECT ==================== */
.status-select { min-width: 110px; font-size: 0.78rem !important; }

/* ==================== CLOSED ROW ==================== */
tr.case-closed-row td { opacity: 0.7; }
tr.case-closed-row td:first-child { opacity: 1; }

/* ==================== READ-ONLY BANNER ==================== */
.readonly-banner {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fef3c7; border: 1px solid #fcd34d; color: #92400e;
  border-radius: 8px; padding: 6px 14px;
  font-size: 0.82rem; font-weight: 500;
}

/* ==================== SLA MINI ==================== */
.sla-mini { min-width: 130px; }

/* ==================== TOAST ==================== */
#toastContainer {
  position: fixed; top: 16px; right: 16px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); z-index: 1050; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}
@media (max-width: 767.98px) {
  .page-content { padding: 16px; }
  .kpi-value { font-size: 1.5rem; }
  .topbar { padding: 10px 16px; }
  .login-card { padding: 28px 20px; }
}

/* ==================== TIMELINE ==================== */
.timeline {
  position: relative;
  padding-left: 44px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 16px;
  bottom: 16px;
  width: 2px;
  background: #e2e8f0;
}
.timeline-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  margin-bottom: 14px;
}
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -44px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.timeline-body {
  flex: 1;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

/* ==================== 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; }

/* ==================== SLA CONFIG ==================== */
.sla-row-card {
  transition: box-shadow 0.15s;
}
.sla-row-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.sla-sev-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sla-input {
  max-width: 80px;
  text-align: center;
}
.sla-unit-select {
  max-width: 90px;
}

/* ==================== AUDIT TRAIL ==================== */
.audit-table th, .audit-table td {
  vertical-align: middle;
  font-size: 0.8rem;
}
.audit-action-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.table-danger-light  { background: rgba(239,68,68,0.05); }
.table-success-light { background: rgba(34,197,94,0.05); }

/* ==================== PRINT ==================== */
@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  .main-content { margin: 0; }
}
