/* =====================================================
   ANES IT Helpdesk — Premium Light Theme
   ===================================================== */

:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --primary-bg: #eef2ff;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.10);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ===================== LAYOUT ===================== */
.app-layout { display: flex; min-height: 100vh; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease, width .25s ease;
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.sidebar-logo { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo-icon {
  width: 38px; height: 38px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px;
  box-shadow: 0 4px 12px rgba(79,70,229,.3);
}

.logo-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.logo-title { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: .5px; white-space: nowrap; }
.logo-sub { font-size: 10px; color: var(--text-3); font-weight: 500; letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; }

.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: 16px; padding: 6px;
  border-radius: 6px; transition: all .2s; flex-shrink: 0;
  min-width: 32px; min-height: 32px; display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle:hover { background: var(--surface-2); color: var(--primary); }

/* Sidebar Nav */
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section { margin-bottom: 24px; }

.nav-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-3);
  padding: 0 8px; margin-bottom: 6px; display: block;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  transition: all .18s; margin-bottom: 2px;
  min-height: 42px;
}
.nav-item i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: var(--primary-bg); color: var(--primary); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.nav-item.active i { color: var(--primary); }

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--border-light);
  padding: 12px;
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

.sidebar-user {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm);
  transition: background .2s; min-width: 0;
}
.sidebar-user:hover { background: var(--surface-2); }

.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 13px; font-weight: 600;
  flex-shrink: 0; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10.5px; color: var(--text-3); }

.logout-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); flex-shrink: 0; transition: all .2s;
}
.logout-btn:hover { background: #fee2e2; color: var(--danger); }

/* Sidebar overlay — mobile backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ===================== MAIN CONTENT ===================== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  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;
  box-shadow: var(--shadow);
  gap: 12px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.breadcrumb-area { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Mobile toggle — hidden on desktop, shown on mobile */
.mobile-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: 18px; padding: 6px;
  border-radius: 6px; transition: all .2s; flex-shrink: 0;
  min-width: 36px; min-height: 36px; align-items: center; justify-content: center;
}
.mobile-toggle:hover { background: var(--surface-2); color: var(--primary); }

.topbar-user .user-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 600; cursor: pointer;
  overflow: hidden; flex-shrink: 0;
}
.topbar-user .user-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

/* Page Content */
.page-content { flex: 1; padding: 28px; }

/* ===================== MESSAGES ===================== */
.messages-area { margin-bottom: 20px; }

.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.alert i { font-size: 15px; flex-shrink: 0; }
.alert-close { margin-left: auto; background: none; border: none; cursor: pointer; opacity: .6; transition: opacity .2s; padding: 4px; min-width: 24px; min-height: 24px; display: flex; align-items: center; justify-content: center; }
.alert-close:hover { opacity: 1; }
.alert-success { background: #d1fae5; color: #065f46; border-left: 3px solid #10b981; }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 3px solid #ef4444; }
.alert-info { background: #dbeafe; color: #1e40af; border-left: 3px solid #3b82f6; }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 3px solid #f59e0b; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all .18s;
  line-height: 1; white-space: nowrap; flex-shrink: 0;
  min-height: 38px;
}
.btn-sm { padding: 7px 14px; font-size: 12.5px; min-height: 34px; }
.btn-lg { padding: 12px 24px; font-size: 15px; min-height: 46px; }

.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: 0 4px 12px rgba(79,70,229,.3); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: #059669; box-shadow: 0 4px 12px rgba(16,185,129,.3); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: white; border-color: var(--warning); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

/* ===================== CARDS ===================== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.card-header h3 { font-size: 14.5px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }

/* ===================== STAT CARDS ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: flex-start; justify-content: space-between;
  transition: box-shadow .2s, transform .2s;
  gap: 12px;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.stat-change { font-size: 11.5px; font-weight: 600; margin-top: 8px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.yellow { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.cyan { background: #cffafe; color: #0891b2; }

/* ===================== TABLES ===================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; background: var(--surface); }
thead th {
  padding: 12px 14px;
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px; font-size: 13px; color: var(--text-2);
  border-bottom: 1px solid var(--border-light); vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ===================== BADGES ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-critical { background: #fce7f3; color: #be185d; }
.badge-high { background: #fee2e2; color: #991b1b; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-low { background: #d1fae5; color: #065f46; }
.status-open { background: #dbeafe; color: #1d4ed8; }
.status-assigned { background: #ede9fe; color: #6d28d9; }
.status-progress { background: #cffafe; color: #0e7490; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-resolved { background: #d1fae5; color: #065f46; }
.status-closed { background: #f1f5f9; color: #475569; }
.status-escalated { background: #fee2e2; color: #991b1b; }

/* ── Team availability badges ─────────────────────────────────────────────
   Available = green   (can be given work)
   Absent    = amber   (marked away by their Super Admin)
   Disabled  = grey    (account switched off)                              */
.availability-available { background: #d1fae5; color: #065f46; }
.availability-absent    { background: #fef3c7; color: #92400e; }
.availability-disabled  { background: #f1f5f9; color: #475569; }

/* ===================== FORMS ===================== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.form-label span.req { color: var(--danger); }

.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13.5px;
  font-family: var(--font); transition: border-color .2s, box-shadow .2s;
  outline: none; -webkit-appearance: none; appearance: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-control::placeholder { color: var(--text-3); }
select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 96px; }

.form-grid { display: grid; gap: 18px; }
.form-grid-1 { grid-template-columns: 1fr; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ===================== PAGE HEADER ===================== */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.page-header-left { min-width: 0; }
.page-header h1 { font-size: 20px; font-weight: 800; color: var(--text); }
.page-header p { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex-shrink: 0; }

/* ===================== FILTER BAR ===================== */
.filter-bar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 18px; flex-wrap: wrap;
}
.filter-bar form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; width: 100%; }
.filter-bar .form-control { max-width: 200px; }
.search-input-wrap { position: relative; }
.search-input-wrap i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 13px; pointer-events: none; }
.search-input-wrap .form-control { padding-left: 34px; }

/* ===================== TICKET DETAIL ===================== */
.ticket-id { font-size: 12px; color: var(--text-3); font-weight: 600; letter-spacing: .5px; }
.ticket-title { font-size: 19px; font-weight: 800; color: var(--text); margin: 6px 0; line-height: 1.3; }
.ticket-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); align-items: center; }
.ticket-meta span { display: flex; align-items: center; gap: 6px; }

.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }

.sla-timer {
  background: linear-gradient(135deg, #fff7ed, #fef3c7);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600;
}
.sla-timer.breached { background: linear-gradient(135deg, #fee2e2, #fecaca); border-color: #fca5a5; color: #991b1b; }
.sla-timer.safe { background: linear-gradient(135deg, #d1fae5, #a7f3d0); border-color: #6ee7b7; color: #065f46; }

/* Comments (legacy classes kept) */
.comment-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border-light); }
.comment-item:last-child { border-bottom: none; }
.comment-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-header { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; flex-wrap: wrap; }
.comment-author { font-weight: 700; font-size: 13px; color: var(--text); }
.comment-time { font-size: 11.5px; color: var(--text-3); }
.comment-text { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }

/* History */
.history-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.history-item:last-child { border-bottom: none; }
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 5px; }

/* ===================== DASHBOARD CHARTS ===================== */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.chart-container { position: relative; padding: 16px; height: 260px; }
.engineer-rank { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-light); }
.engineer-rank:last-child { border-bottom: none; }
.rank-num { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank-name { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-count { font-size: 13px; font-weight: 700; color: var(--primary); white-space: nowrap; }

/* ===================== AUTH PAGES ===================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 50%, #f0f9ff 100%);
}

.auth-left {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  width: 100%; max-width: 480px;
  border: 1px solid var(--border);
}

.auth-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.auth-logo .logo-icon { width: 44px; height: 44px; font-size: 18px; }
.auth-logo .logo-title { font-size: 17px; }

.auth-heading { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.auth-sub { font-size: 13.5px; color: var(--text-3); margin-bottom: 24px; }

.auth-footer { font-size: 13px; color: var(--text-3); text-align: center; margin-top: 20px; }
.auth-footer a { color: var(--primary); font-weight: 600; }

.auth-right {
  flex: 1;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
  position: relative; overflow: hidden;
}
.auth-right::before, .auth-right::after { display: none; }
.auth-promo { color: white; position: relative; z-index: 1; max-width: 400px; }
.auth-promo h2 { font-size: 28px; font-weight: 800; line-height: 1.3; margin-bottom: 14px; }
.auth-promo p { font-size: 14px; opacity: .85; line-height: 1.75; }
.auth-promo .features { margin-top: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-promo .feature { display: flex; align-items: center; gap: 12px; font-size: 13.5px; opacity: .9; }
.auth-promo .feature i { font-size: 15px; }

/* ===================== RESPONSIVE LAYOUT HELPERS ===================== */
/* Two-column layouts used in templates */
.r-two-col { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.r-profile-grid { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }
.r-admin-two { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }

/* ===================== UTILITIES ===================== */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-3); }
.text-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 20px; color: var(--text-3);
}
.empty-state i { font-size: 44px; margin-bottom: 14px; opacity: .4; }
.empty-state p { font-size: 14px; font-weight: 500; }

/* Priority dot */
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; flex-shrink: 0; }
.dot-p0 { background: #be185d; }
.dot-p1 { background: #dc2626; }
.dot-p2 { background: #d97706; }
.dot-p3 { background: #059669; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ===================== SIDEBAR COLLAPSED (desktop only) ===================== */
.sidebar-collapsed .sidebar { width: 64px; }
.sidebar-collapsed .sidebar .logo-text,
.sidebar-collapsed .sidebar .nav-item span,
.sidebar-collapsed .sidebar .nav-label,
.sidebar-collapsed .sidebar .user-info,
.sidebar-collapsed .sidebar .logout-btn { display: none; }
.sidebar-collapsed .sidebar .sidebar-logo { justify-content: center; }
.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 10px; }
.sidebar-collapsed .main-content { margin-left: 64px; }

/* ===================== BREAKPOINTS ===================== */

/* 1280px — 4-col stats → 2-col */
@media (max-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 1100px — tighten sidebar */
@media (max-width: 1100px) {
  :root { --sidebar-w: 220px; }
  .auth-promo h2 { font-size: 24px; }
}

/* 1024px — charts & detail grid → single column */
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .r-two-col { grid-template-columns: 1fr; }
  .r-profile-grid { grid-template-columns: 1fr; }
  .r-admin-two { grid-template-columns: 1fr; }
}

/* 900px — mobile: sidebar off-screen */
@media (max-width: 900px) {
  :root { --topbar-h: 58px; }

  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0 !important; }

  .mobile-toggle { display: flex; }
  .sidebar-toggle { display: none; }

  /* Disable desktop collapse on mobile */
  .sidebar-collapsed .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar-collapsed .sidebar .logo-text,
  .sidebar-collapsed .sidebar .nav-item span,
  .sidebar-collapsed .sidebar .nav-label,
  .sidebar-collapsed .sidebar .user-info,
  .sidebar-collapsed .sidebar .logout-btn { display: flex; }
  .sidebar-collapsed .sidebar .nav-item { justify-content: flex-start; padding: 10px 12px; }

  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }

  .auth-right { display: none; }
  .auth-left { padding: 16px; }
  .auth-card { padding: 28px 20px; max-width: 100%; border-radius: 16px; }

  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; }

  /* Stack page-header vertically on mobile */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header-actions { width: 100%; }

  /* Filter bar full-width inputs */
  .filter-bar form { gap: 8px; }
  .filter-bar .form-control { max-width: 100%; flex: 1; min-width: 120px; }

  /* Topbar tweaks */
  .topbar-right .btn-sm span { display: none; } /* hide "New Ticket" label on small screens */
  .topbar-right .btn-sm { padding: 7px 10px; }
}

/* 768px — tighten further */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }
  .stat-icon { width: 38px; height: 38px; font-size: 16px; }

  .chart-container { height: 220px; }

  /* Hide low-priority table columns on mobile */
  .hide-mobile { display: none !important; }

  .table-wrapper { border-radius: var(--radius-sm); }
  thead th, tbody td { padding: 10px 12px; }
}

/* 480px — single column everything */
@media (max-width: 480px) {
  html { font-size: 13px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 22px; }

  .auth-card { padding: 24px 16px; }
  .auth-heading { font-size: 20px; }

  .btn-lg { padding: 11px 18px; font-size: 14px; }

  .page-content { padding: 12px; }
  .card-body { padding: 14px; }
}

/* Touch devices — increase tap targets */
@media (hover: none) and (pointer: coarse) {
  .nav-item { min-height: 46px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 38px; }
  .form-control { min-height: 46px; font-size: 16px; } /* prevent iOS zoom */
}
