/* ============================================================
   Fixa HelpDesk — Master Stylesheet
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --blue:       #1f5883;
  --blue-dark:  #163f61;
  --blue-mid:   #2a6fa0;
  --blue-pale:  #e8f2fa;
  --blue-ghost: #f0f7fc;
  --accent:     #f0a500;
  --text-dark:  #0d1f2d;
  --text-mid:   #2c4a62;
  --text-light: #5a7a94;
  --white:      #ffffff;
  --gray-bg:    #f4f8fc;
  --border:     #cce0f0;
  --shadow:     rgba(31,88,131,0.10);
  --shadow-lg:  rgba(31,88,131,0.18);
  --sidebar-w:  260px;
  --header-h:   64px;
  --radius:     12px;
  --radius-sm:  8px;
  --font:       'Cairo', 'Tajawal', system-ui, sans-serif;
  /* Status colors */
  --s-open:     #1f5883;
  --s-pending:  #f59e0b;
  --s-progress: #3b82f6;
  --s-resolved: #22c55e;
  --s-closed:   #94a3b8;
  /* Priority */
  --p-low:      #94a3b8;
  --p-medium:   #f59e0b;
  --p-high:     #f97316;
  --p-urgent:   #ef4444;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--gray-bg);
  color: var(--text-dark);
  line-height: 1.6;
  direction: rtl;
}
[dir="ltr"] body, body[dir="ltr"] { direction: ltr; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-mid); }
img { max-width: 100%; }
ul { list-style: none; }

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 1.8rem; font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
h4 { font-size: 1rem; font-weight: 600; }

/* ── App Layout ─────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--text-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0;
  inset-inline-start: 0;
  z-index: 200;
  transition: transform 0.3s;
}
.sidebar-logo {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: var(--blue);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: white;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: 15px;
  font-weight: 800;
  color: white;
  line-height: 1.2;
}
.sidebar-logo .logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; scrollbar-width: thin; scrollbar-color: var(--blue) rgba(255,255,255,0.05); }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--blue); border-radius: 4px; border: 1px solid rgba(255,255,255,0.1); }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--blue-mid); }

.nav-section-label {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 0;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: white; }
.nav-item.active {
  background: rgba(31,88,131,0.4);
  color: white;
  border-inline-end: 3px solid var(--accent);
}
.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-inline-start: auto;
  background: var(--p-urgent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 50px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}
.sidebar-user .user-info strong { display: block; font-size: 13px; color: white; }
.sidebar-user .user-info span { font-size: 11px; color: rgba(255,255,255,0.45); }
.sidebar-user .logout-btn {
  margin-inline-start: auto;
  color: rgba(255,255,255,0.45);
  font-size: 18px;
  transition: color 0.2s;
}
.sidebar-user .logout-btn:hover { color: var(--p-urgent); }

/* Main content */
.main-content {
  margin-inline-start: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  z-index: 100;
  box-shadow: 0 2px 10px var(--shadow);
}
.header-title { font-size: 17px; font-weight: 800; color: var(--text-dark); flex: 1; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-dark);
  padding: 4px;
}

/* Page content */
.page-content { padding: 28px; flex: 1; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 8px var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { margin: 0; }

/* ── Stat Cards (Dashboard) ─────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px var(--shadow-lg); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--blue-pale); }
.stat-icon.amber  { background: #fff8e1; }
.stat-icon.green  { background: #e8f5e9; }
.stat-icon.purple { background: #f3e8ff; }
.stat-info .stat-num   { font-size: 28px; font-weight: 900; color: var(--text-dark); line-height: 1; }
.stat-info .stat-label { font-size: 12px; color: var(--text-light); margin-top: 3px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--blue); color: white; box-shadow: 0 3px 12px rgba(31,88,131,.3); }
.btn-primary:hover { background: var(--blue-dark); color: white; transform: translateY(-1px); }
.btn-secondary { background: var(--blue-pale); color: var(--blue); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--blue); }
.btn-danger    { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #dc2626; color: white; }
.btn-success   { background: #dcfce7; color: #16a34a; border-color: #bbf7d0; }
.btn-success:hover { background: #16a34a; color: white; }
.btn-outline   { background: transparent; color: var(--text-mid); border-color: var(--border); }
.btn-outline:hover { background: var(--gray-bg); }
.btn-sm { padding: 6px 13px; font-size: 12px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; border-radius: var(--radius-sm); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
/* Status */
.badge-open     { background: #dbeafe; color: #1d4ed8; }
.badge-pending  { background: #fef9c3; color: #854d0e; }
.badge-progress { background: #e0f2fe; color: #0369a1; }
.badge-resolved { background: #dcfce7; color: #15803d; }
.badge-closed   { background: #f1f5f9; color: #64748b; }
/* Priority */
.badge-low    { background: #f1f5f9; color: #64748b; }
.badge-medium { background: #fef9c3; color: #854d0e; }
.badge-high   { background: #ffedd5; color: #c2410c; }
.badge-urgent { background: #fee2e2; color: #dc2626; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-mid);
  margin-bottom: 6px;
}
.form-label .req { color: var(--p-urgent); margin-inline-start: 3px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--gray-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-dark);
  outline: none;
  transition: all 0.2s;
  direction: inherit;
}
.form-control:focus {
  border-color: var(--blue);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(31,88,131,0.12);
}
.form-control.is-invalid { border-color: var(--p-urgent); }
.form-hint  { font-size: 12px; color: var(--text-light); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--p-urgent); margin-top: 5px; }
textarea.form-control { resize: vertical; min-height: 120px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] { width: 16px; height: 16px; accent-color: var(--blue); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  padding: 11px 14px;
  background: var(--blue-ghost);
  color: var(--text-mid);
  font-weight: 700;
  font-size: 12px;
  text-align: start;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dark);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--blue-ghost); }
.table .tc { text-align: center; }

/* ── Ticket Detail Layout ───────────────────────────────────── */
.ticket-detail-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}
.ticket-main-col { display: flex; flex-direction: column; gap: 20px; }
.ticket-side-col { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--header-h) + 16px); }

.ticket-meta-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tmc-header {
  background: var(--blue);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tmc-header h4 { color: white; font-size: 14px; margin: 0; }
.tmc-body { padding: 16px; }
.tmc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.tmc-row:last-child { border-bottom: none; }
.tmc-row .tmc-key { color: var(--text-light); font-weight: 600; }
.tmc-row .tmc-val { font-weight: 700; color: var(--text-dark); text-align: end; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item {
  display: flex;
  gap: 14px;
  position: relative;
  padding-bottom: 20px;
}
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: '';
  position: absolute;
  inset-inline-start: 19px;
  top: 36px;
  width: 2px;
  height: calc(100% - 36px);
  background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  z-index: 1;
}
.tl-dot.reply   { background: var(--blue-pale); }
.tl-dot.note    { background: #fef9c3; }
.tl-dot.status  { background: #dcfce7; }
.tl-dot.assign  { background: #e0f2fe; }
.tl-dot.created { background: var(--blue); color: white; }
.tl-dot.closed  { background: #f1f5f9; }
.tl-body { flex: 1; }
.tl-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.tl-meta strong { color: var(--text-dark); font-size: 13px; }
.tl-bubble {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dark);
}
.tl-bubble.internal {
  background: #fffbeb;
  border-color: #fde68a;
}
.tl-bubble.agent-bubble {
  background: var(--blue-ghost);
  border-color: var(--border);
}
.tl-action-event {
  background: var(--gray-bg);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-light);
  display: inline-block;
}

/* ── Reply Box ──────────────────────────────────────────────── */
.reply-box { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.reply-tabs { display: flex; gap: 0; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.reply-tab {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font);
  transition: all 0.2s;
}
.reply-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.reply-tab:hover  { color: var(--blue); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.alert-warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.alert-info    { background: var(--blue-pale); color: var(--blue); border: 1px solid var(--border); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 20px; }
.pg-btn {
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-mid);
  background: var(--white);
  transition: all 0.2s;
  text-decoration: none;
}
.pg-btn:hover { background: var(--blue); color: white; border-color: var(--blue); }
.pg-btn.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ── Filters bar ────────────────────────────────────────────── */
.filters-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filters-bar .form-control { max-width: 180px; }
.filters-bar .search-input { max-width: 260px; }

/* ── Auth Pages ─────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-bg);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 12px 40px var(--shadow-lg);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo .logo-icon {
  width: 56px; height: 56px;
  background: var(--blue);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 900;
  color: white;
  margin: 0 auto 12px;
}
.auth-logo h1 { font-size: 22px; font-weight: 900; color: var(--text-dark); }
.auth-logo p  { font-size: 13px; color: var(--text-light); }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-light); }
.auth-divider { text-align: center; margin: 16px 0; font-size: 12px; color: var(--text-light); position: relative; }
.auth-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.auth-divider span { background: white; padding: 0 12px; position: relative; }

/* ── Select2 style for select ───────────────────────────────── */
.form-select {
  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 d='M1 1l5 5 5-5' stroke='%235a7a94' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
  appearance: none;
}
[dir="rtl"] .form-select {
  background-position: right 12px center;
  padding-left: 14px;
  padding-right: 32px;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--white);
  border-radius: 18px;
  padding: 28px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-light); }

/* ── Search bar ─────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  transition: all 0.2s;
}
.search-bar:focus-within { border-color: var(--blue); background: white; }
.search-bar input { border: none; background: transparent; outline: none; font-family: var(--font); font-size: 14px; flex: 1; padding: 9px 0; direction: inherit; }
.search-bar span { color: var(--text-light); font-size: 16px; }

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }

/* ── Public (guest) pages ───────────────────────────────────── */
.public-header {
  background: var(--text-dark);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.public-hero {
  background: linear-gradient(135deg, var(--blue), var(--blue-mid));
  padding: 60px 24px;
  text-align: center;
  color: white;
}
.public-hero h1 { font-size: clamp(24px,4vw,40px); font-weight: 900; margin-bottom: 10px; }
.public-hero p  { font-size: 16px; opacity: 0.85; }
.public-content { max-width: 860px; margin: 0 auto; padding: 40px 24px; }

/* ── Upload Area ────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-light);
  font-size: 13px;
}
.upload-area:hover { border-color: var(--blue); background: var(--blue-ghost); }
.upload-area input { display: none; }
.attached-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attached-file {
  background: var(--blue-ghost);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  gap: 6px;
}
.attached-file .rm { cursor: pointer; color: var(--p-urgent); }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-light);
}
.empty-state .es-icon { font-size: 56px; margin-bottom: 14px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text-mid); }
.empty-state p  { font-size: 14px; }

/* ── QR 2FA ─────────────────────────────────────────────────── */
.qr-box { text-align: center; padding: 24px; }
.qr-box img { border-radius: var(--radius); border: 4px solid var(--border); }
.secret-code {
  font-family: monospace;
  font-size: 15px;
  letter-spacing: 3px;
  background: var(--gray-bg);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-dark);
  display: inline-block;
  margin-top: 10px;
}

/* ── Rating stars ───────────────────────────────────────────── */
.star-rating { display: flex; gap: 6px; }
.star-rating label {
  font-size: 28px;
  cursor: pointer;
  color: var(--border);
  transition: color 0.2s;
}
.star-rating input { display: none; }
.star-rating label:hover,
.star-rating input:checked ~ label,
.star-rating label:hover ~ label { color: var(--accent); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .ticket-detail-layout { grid-template-columns: 1fr; }
  .ticket-side-col { position: static; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar { transform: translateX(100%); }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-inline-start: 0; }
  .menu-toggle { display: block; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .app-header { padding: 0 16px; }
  .filters-bar { gap: 8px; }
  .filters-bar .form-control { max-width: 140px; }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .auth-card { padding: 24px; }
}

/* ── Utility ────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.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; }
.text-muted { color: var(--text-light); }
.text-small { font-size: 12px; }
.fw-bold { font-weight: 700; }
.text-center { text-align: center; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; display: inline-block; }

/* ============================================================
   LAYOUT SWITCHER ADDITIONS v1.1
   ============================================================ */

/* Sidebar collapsed - icon-only mode */
.sidebar.collapsed { width: var(--sidebar-collapsed-w, 64px); }
/* Hide text in collapsed mode */
.sidebar.collapsed .logo-text,
.sidebar.collapsed .logo-sub,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-info { display: none !important; }
/* Keep logout visible but icon-only */
.sidebar.collapsed .logout-text { display: none !important; }
/* Collapsed layout adjustments */
.sidebar.collapsed .sidebar-logo { padding: 16px 0; justify-content: center; }
.sidebar.collapsed .nav-item { padding: 13px 0; justify-content: center; gap: 0; min-height: 46px; }
.sidebar.collapsed .nav-item .nav-icon { font-size: 21px; width: auto; }
.sidebar.collapsed .sidebar-footer { padding: 10px 0; }
.sidebar.collapsed .sidebar-user { justify-content: center; flex-direction: column; gap: 8px; padding: 0; }
.sidebar.collapsed .sidebar-user .user-avatar { margin: 0; }
/* Collapse icon-only logout/profile buttons */
.sidebar.collapsed .sidebar-user-actions { flex-direction: column; gap: 4px; justify-content: center; align-items: center; }

/* Sidebar collapse toggle button */
.sidebar-collapse-btn {
  position: absolute;
  top: 20px;
  inset-inline-end: -13px;
  width: 26px; height: 26px;
  background: var(--blue);
  border: 2px solid white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 10px;
  color: white;
  z-index: 10;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  line-height: 1;
}
.sidebar-collapse-btn:hover { background: var(--blue-dark); transform: scale(1.1); }

/* Tooltip for collapsed sidebar nav items */
.sidebar.collapsed .nav-item { position: relative; overflow: visible; }
.sidebar.collapsed .nav-item::after {
  content: attr(data-title);
  position: absolute;
  inset-inline-start: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(13,31,45,0.97);
  color: white;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  font-family: var(--font);
  border: 1px solid rgba(255,255,255,0.1);
}
.sidebar.collapsed .nav-item::before {
  content: '';
  position: absolute;
  inset-inline-start: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-inline-end-color: rgba(13,31,45,0.97);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 9999;
}
.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .nav-item:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Main content adjusts when sidebar collapses */
.sidebar.collapsed ~ .main-content {
  margin-inline-start: var(--sidebar-collapsed-w, 64px) !important;
}

/* ---- TOPNAV LAYOUT ---- */
body.layout-topnav .app-wrapper { flex-direction: column; }
body.layout-topnav .sidebar { display: none !important; }
body.layout-topnav .main-content { margin-inline-start: 0 !important; }
body.layout-topnav .app-header { display: none; }

.topnav {
  display: none;
  width: 100%;
  background: var(--text-dark);
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 200;
  align-items: center;
  padding: 0 20px;
  gap: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
  flex-shrink: 0;
}
body.layout-topnav .topnav { display: flex; }

.topnav-logo {
  display: flex; align-items: center; gap: 9px;
  margin-inline-end: 20px;
  text-decoration: none; flex-shrink: 0;
}
.topnav-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--blue); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 900; color: white;
}
.topnav-logo span { font-size: 14px; font-weight: 800; color: white; white-space: nowrap; }

.topnav-links {
  display: flex; align-items: center; gap: 2px;
  flex: 1; overflow-x: auto; scrollbar-width: none;
}
.topnav-links::-webkit-scrollbar { display: none; }

.topnav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; color: rgba(255,255,255,0.65);
  font-size: 13px; font-weight: 600;
  border-radius: 7px; white-space: nowrap;
  transition: all 0.2s; cursor: pointer; text-decoration: none;
}
.topnav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.topnav-item.active { background: rgba(31,88,131,0.5); color: white; }
.topnav-item .nav-icon { font-size: 14px; }

.topnav-badge {
  background: var(--p-urgent); color: white;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 50px;
}

.topnav-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.1); margin: 0 5px; flex-shrink: 0; }

.topnav-right {
  display: flex; align-items: center; gap: 8px;
  margin-inline-start: 12px; flex-shrink: 0;
}
.topnav-user {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,0.75); font-size: 13px; font-weight: 600;
}
.topnav-user .user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%; background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: white;
}
body.layout-topnav .ticket-side-col { top: 76px; }

/* CAPTCHA box */
.captcha-box { background: var(--blue-ghost); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; display: flex; align-items: center; gap: 14px; }
.captcha-question { font-size: 18px; font-weight: 900; color: var(--blue); font-family: monospace; letter-spacing: 2px; flex: 1; user-select: none; }
.captcha-refresh { cursor: pointer; font-size: 18px; color: var(--text-light); transition: transform 0.3s; border: none; background: none; }
.captcha-refresh:hover { transform: rotate(180deg); color: var(--blue); }

@media(max-width:768px) {
  .sidebar.collapsed { width: var(--sidebar-w) !important; }
  .sidebar.collapsed .logo-text,
  .sidebar.collapsed .logo-sub,
  .sidebar.collapsed .nav-section-label,
  .sidebar.collapsed .nav-badge,
  .sidebar.collapsed .user-info,
  .sidebar.collapsed .logout-text { display: block !important; }
  .sidebar.collapsed .logout-btn { display: flex !important; }
  .sidebar.collapsed .nav-item { padding: 10px 20px; justify-content: flex-start; gap: 10px; overflow: hidden; }
  .sidebar.collapsed .nav-item::after,
  .sidebar.collapsed .nav-item::before { display: none !important; }
  .sidebar.collapsed .nav-item .nav-icon { width: 22px; font-size: 18px; }
  .sidebar.collapsed .sidebar-logo { padding: 18px 20px; justify-content: flex-start; }
  .sidebar.collapsed .sidebar-footer { padding: 14px 20px; }
  .sidebar.collapsed .sidebar-user { flex-direction: row; gap: 10px; }
  .sidebar.collapsed .sidebar-user-actions { flex-direction: row; gap: 6px; }
  .sidebar-collapse-btn { display: none; }
  .topnav-links { display: none; }
}

/* ── Logout button (Power icon style) ──────────────────────── */
.sidebar-user-actions {
  display: flex;
  gap: 5px;
  margin-inline-start: auto;
  align-items: center;
}
.logout-btn span {
  display: block;
  line-height: 1;
}
/* Power off icon styling */
.logout-exit span { font-size: 14px; }
.logout-btn {
  position: relative;
}
.logout-btn:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: rgba(13,31,45,.95);
  color: white;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
}

/* ── Sidebar scrollbar - make it a visible accent ───────────── */
.sidebar-nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(31,88,131,0.7) rgba(255,255,255,0.05);
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.04);
  margin: 6px 0;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--blue-mid), var(--blue));
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--accent), var(--blue-mid));
}

/* Ensure collapsed main-content has no jump */
.main-content {
  transition: margin-inline-start 0.25s ease;
}
