/* University of Anbar — Citizens Affairs
   Custom theme on top of Bootstrap 5 RTL. Mobile-first, modern, professional. */

:root {
  --color-primary: #1d4ed8;
  --color-primary-dark: #1e40af;
  --color-primary-soft: #eef2ff;
  --color-accent: #15803d;
  --color-accent-soft: #dcfce7;
  --color-warn: #b45309;
  --color-warn-soft: #fef3c7;
  --color-danger: #b91c1c;
  --color-danger-soft: #fee2e2;
  --color-bg: #f6f7fb;
  --color-card: #ffffff;
  --color-card-2: #ffffff;
  --color-text: #1f2d3d;
  --color-muted: #64748b;
  --color-border: #e2e8f0;
  --color-input: #ffffff;
  --color-input-border: #e2e8f0;
  --color-input-text: #1f2d3d;
  --color-table-head: #f8fafc;
  --color-table-hover: #f8fafc;
  --color-input-group-prefix: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.03);
  --shadow-md: 0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --radius: 12px;
  color-scheme: light;
}

/* === DARK THEME === activated by html[data-theme="dark"] === */
html[data-theme="dark"] {
  --color-primary: #60a5fa;
  --color-primary-dark: #3b82f6;
  --color-primary-soft: #1e293b;
  --color-accent: #34d399;
  --color-accent-soft: #064e3b;
  --color-warn: #fbbf24;
  --color-warn-soft: #422006;
  --color-danger: #f87171;
  --color-danger-soft: #450a0a;
  --color-bg: #0b1220;
  --color-card: #111827;
  --color-card-2: #0f172a;
  --color-text: #e5e7eb;
  --color-muted: #94a3b8;
  --color-border: #1f2937;
  --color-input: #1f2937;
  --color-input-border: #334155;
  --color-input-text: #f1f5f9;
  --color-table-head: #0f172a;
  --color-table-hover: #1f2937;
  --color-input-group-prefix: #1e293b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35), 0 1px 1px rgba(0,0,0,.30);
  --shadow-md: 0 4px 12px rgba(0,0,0,.45), 0 2px 4px rgba(0,0,0,.35);
  color-scheme: dark;
}
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] textarea.form-control {
  background: var(--color-input);
  border-color: var(--color-input-border);
  color: var(--color-input-text);
}
html[data-theme="dark"] .input-group .prefix { background: var(--color-input-group-prefix); border-color: var(--color-input-border); color: var(--color-text); }
html[data-theme="dark"] .table-modern { background: var(--color-card); border-color: var(--color-border); }
html[data-theme="dark"] .table-modern thead th { background: var(--color-table-head); color: var(--color-muted); border-color: var(--color-border); }
html[data-theme="dark"] .table-modern tbody td { border-color: var(--color-border); }
html[data-theme="dark"] .table-modern tbody tr:hover { background: var(--color-table-hover); }
html[data-theme="dark"] .card-soft { background: var(--color-card); border-color: var(--color-border); }
html[data-theme="dark"] .card-soft .card-header { border-color: var(--color-border); }
html[data-theme="dark"] .empty { background: var(--color-card); border-color: var(--color-border); }
html[data-theme="dark"] .filter-bar { background: var(--color-card); border-color: var(--color-border); }
html[data-theme="dark"] .kpi { background: var(--color-card); border-color: var(--color-border); }
html[data-theme="dark"] .auth-shell { background: linear-gradient(135deg, #020617 0%, #1e3a8a 100%); }
html[data-theme="dark"] .auth-card { background: var(--color-card); }
html[data-theme="dark"] .landing { background: linear-gradient(135deg, #020617 0%, #1e3a8a 100%); }
html[data-theme="dark"] .landing .features { background: var(--color-bg); color: var(--color-text); }
html[data-theme="dark"] .landing .feature { background: var(--color-card); border-color: var(--color-border); }
html[data-theme="dark"] .alert-info    { background: #082f49; color: #bae6fd; border-color: #075985; }
html[data-theme="dark"] .alert-success { background: #052e1a; color: #bbf7d0; border-color: #166534; }
html[data-theme="dark"] .alert-warn    { background: #451a03; color: #fde68a; border-color: #b45309; }
html[data-theme="dark"] .alert-danger  { background: #450a0a; color: #fecaca; border-color: #b91c1c; }
html[data-theme="dark"] .btn-ghost { background: transparent; color: var(--color-text); border-color: var(--color-border); }
html[data-theme="dark"] .btn-ghost:hover { background: var(--color-card-2); }
html[data-theme="dark"] .form-floating-card { background: var(--color-card); border-color: var(--color-border); }
html[data-theme="dark"] .timeline::before { background: var(--color-border); }
html[data-theme="dark"] .timeline-item::before { background: var(--color-card); border-color: var(--color-primary); }
html[data-theme="dark"] .timeline-item.done::before { background: var(--color-primary); }
html[data-theme="dark"] .badge-status.bg-info-lt { background: #082f49; }   html[data-theme="dark"] .text-info { color: #7dd3fc; }
html[data-theme="dark"] .badge-status.bg-yellow-lt { background: #422006; } html[data-theme="dark"] .text-yellow-fg { color: #fbbf24; }
html[data-theme="dark"] .badge-status.bg-purple-lt { background: #2e1065; } html[data-theme="dark"] .text-purple { color: #c4b5fd; }
html[data-theme="dark"] .badge-status.bg-green-lt { background: #052e1a; }  html[data-theme="dark"] .text-green { color: #86efac; }
html[data-theme="dark"] .badge-status.bg-red-lt { background: #450a0a; }    html[data-theme="dark"] .text-red { color: #fca5a5; }
html[data-theme="dark"] .badge-status.bg-secondary-lt { background: #1f2937; } html[data-theme="dark"] .text-secondary { color: #cbd5e1; }
html[data-theme="dark"] .divider { background: var(--color-border); }
html[data-theme="dark"] .form-hint { color: var(--color-muted); }

/* Dark mode adjustments for the inline-styled "request body" blocks
   (these are unfortunately styled with hardcoded backgrounds in views;
    these rules override them via attribute selectors). */
html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background: #f8fafc"] {
  background: var(--color-card-2) !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}
html[data-theme="dark"] [style*="background:#fef3c7"] {
  background: #422006 !important; color: #fde68a !important; border-color: #b45309 !important;
}
html[data-theme="dark"] [style*="background:#eef2ff"] {
  background: #1e1b4b !important; color: #c7d2fe !important;
}
html[data-theme="dark"] details { background: var(--color-card) !important; color: var(--color-text); border-color: var(--color-border) !important; }
html[data-theme="dark"] summary { color: var(--color-text); }
html[data-theme="dark"] code { background: var(--color-card-2); color: var(--color-text); padding: 1px 4px; border-radius: 4px; }

/* Theme toggle button */
.theme-toggle {
  background: transparent; border: 1px solid var(--color-border);
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; color: var(--color-text);
  transition: background .15s, transform .15s;
}
.theme-toggle:hover { background: var(--color-primary-soft); transform: rotate(15deg); }
html[data-theme="dark"] .theme-toggle { border-color: var(--color-border); }
.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: inline; }
html[data-theme="dark"] .theme-toggle .sun-icon { display: inline; }
html[data-theme="dark"] .theme-toggle .moon-icon { display: none; }
.theme-toggle.on-dark { color: #fff; border-color: rgba(255,255,255,.3); }
.theme-toggle.on-dark:hover { background: rgba(255,255,255,.1); }

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); text-decoration: underline; }

/* ===== APP SHELL ===== */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #cbd5e1;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.app-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid rgba(148,163,184,.15);
  margin-bottom: 16px;
}
.app-sidebar .brand img { width: 44px; height: 44px; object-fit: contain; }
.app-sidebar .brand .title { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.3; }
.app-sidebar .brand .subtitle { color: #94a3b8; font-size: 11px; }
.app-sidebar a.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; color: #cbd5e1;
  font-size: 14px; transition: background .15s, color .15s;
}
.app-sidebar a.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.app-sidebar a.nav-item.active { background: rgba(29,78,216,.25); color: #fff; }
.app-sidebar .nav-section {
  font-size: 11px; color: #64748b; text-transform: uppercase;
  letter-spacing: 1px; padding: 18px 12px 6px;
}

.app-main { flex: 1; min-width: 0; padding: 24px 32px 56px; }
.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.app-topbar h1 { font-size: 22px; margin: 0; font-weight: 700; }
.app-topbar .subtitle { color: var(--color-muted); font-size: 13px; margin-top: 2px; }

@media (max-width: 991px) {
  .app-sidebar { position: fixed; right: -280px; transition: right .25s; z-index: 1050; }
  .app-sidebar.open { right: 0; }
  .app-main { padding: 16px; }
  .app-shell.has-sidebar-open::before {
    content: ''; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 1040;
  }
}
/* Desktop hamburger: collapses the sidebar to give more screen real estate. */
.app-shell.sidebar-collapsed .app-sidebar { width: 64px; padding: 16px 8px; }
.app-shell.sidebar-collapsed .app-sidebar .brand .title,
.app-shell.sidebar-collapsed .app-sidebar .brand .subtitle,
.app-shell.sidebar-collapsed .app-sidebar a.nav-item span:not(:first-child),
.app-shell.sidebar-collapsed .app-sidebar .nav-section,
.app-shell.sidebar-collapsed .app-sidebar .small { display: none; }
.app-shell.sidebar-collapsed .app-sidebar a.nav-item { justify-content: center; }
.sidebar-burger { padding: 6px 12px; font-size: 18px; line-height: 1; }

/* ===== CARDS ===== */
.card-soft {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-soft .card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}
.card-soft .card-body { padding: 20px; }

/* ===== KPI ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm);
}
.kpi .icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
  background: var(--color-primary-soft); color: var(--color-primary);
}
.kpi .label { font-size: 13px; color: var(--color-muted); }
.kpi .value { font-size: 22px; font-weight: 700; line-height: 1.2; }

/* ===== STATUS BADGES ===== */
.badge-status {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1;
}
.bg-info-lt { background: #e0f2fe; }   .text-info { color: #075985; }
.bg-yellow-lt { background: #fef3c7; } .text-yellow-fg { color: #92400e; }
.bg-purple-lt { background: #ede9fe; } .text-purple { color: #5b21b6; }
.bg-green-lt { background: #dcfce7; }  .text-green { color: #166534; }
.bg-red-lt { background: #fee2e2; }    .text-red { color: #991b1b; }
.bg-secondary-lt { background: #e2e8f0; } .text-secondary { color: #475569; }

/* ===== FORM ===== */
.form-card { max-width: 720px; margin: 0 auto; }
.form-floating-card {
  background: #fff; border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 28px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 6px; display: block; color: var(--color-text); }
.form-hint { color: var(--color-muted); font-size: 12px; margin-top: 4px; }
.form-control, .form-select, textarea.form-control {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--color-border); border-radius: 10px;
  font-family: inherit; font-size: 14px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus, textarea.form-control:focus {
  outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(29,78,216,.15);
}
textarea.form-control { min-height: 120px; resize: vertical; }
.input-group { display: flex; align-items: stretch; }
.input-group .prefix {
  background: #f1f5f9; border: 1px solid var(--color-border); border-left: 0;
  padding: 0 12px; display: flex; align-items: center; font-weight: 600;
  border-radius: 0 10px 10px 0;
}
.input-group .form-control { border-radius: 10px 0 0 10px; }
[dir="rtl"] .input-group .prefix { border-radius: 10px 0 0 10px; border-left: 1px solid var(--color-border); border-right: 0; }
[dir="rtl"] .input-group .form-control { border-radius: 0 10px 10px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, transform .05s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; text-decoration: none; }
.btn-outline { background: #fff; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary-soft); color: var(--color-primary); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #991b1b; color: #fff; }
.btn-success { background: var(--color-accent); color: #fff; }
.btn-success:hover { background: #166534; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ===== TABLE ===== */
.table-modern {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); border: 1px solid var(--color-border);
}
.table-modern thead th {
  background: #f8fafc; color: var(--color-muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  text-align: right; padding: 12px 16px; border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}
.table-modern tbody td { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; font-size: 14px; vertical-align: middle; }
.table-modern tbody tr:last-child td { border-bottom: 0; }
.table-modern tbody tr:hover { background: #f8fafc; }

/* ===== ALERT ===== */
.alert {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
  font-size: 14px; border: 1px solid transparent;
}
.alert-info    { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-warn    { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-danger  { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-right: 28px; }
.timeline::before { content: ''; position: absolute; right: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--color-border); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before { content: ''; position: absolute; right: -26px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--color-primary); }
.timeline-item.done::before { background: var(--color-primary); }
.timeline-item .meta { font-size: 12px; color: var(--color-muted); }
.timeline-item .title { font-weight: 600; margin: 2px 0; }
.timeline-item .note { color: var(--color-text); font-size: 13px; line-height: 1.6; }

/* ===== AUTH (centered card) ===== */
.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #1e293b 0%, #1e40af 100%);
  padding: 24px;
}
.auth-card {
  background: #fff; border-radius: 16px; box-shadow: 0 25px 60px rgba(15,23,42,.25);
  padding: 36px; width: 100%; max-width: 440px;
}
.auth-card .brand { text-align: center; margin-bottom: 24px; }
.auth-card .brand img { width: 72px; height: 72px; object-fit: contain; margin-bottom: 8px; }
.auth-card .brand .title { font-weight: 700; color: var(--color-text); font-size: 18px; }
.auth-card .brand .subtitle { color: var(--color-muted); font-size: 13px; }
.auth-card h1 { font-size: 20px; margin: 0 0 18px; font-weight: 700; }
.auth-card .links { font-size: 13px; color: var(--color-muted); margin-top: 18px; text-align: center; }

/* ===== LANDING (applicant home) ===== */
.landing { min-height: 100vh; background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 100%); color: #fff; }
.landing .nav { display: flex; justify-content: space-between; align-items: center; padding: 16px 32px; }
.landing .nav .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 14px; }
.landing .nav .brand img { width: 40px; height: 40px; object-fit: contain; }
.landing .hero { padding: 60px 24px 80px; text-align: center; max-width: 880px; margin: 0 auto; }
.landing .hero h1 { font-size: 36px; margin: 16px 0; line-height: 1.3; }
.landing .hero p { font-size: 18px; color: #cbd5e1; line-height: 1.7; }
.landing .hero .cta { margin-top: 28px; display: inline-flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.landing .features { background: #fff; color: var(--color-text); padding: 60px 24px; }
.landing .features-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.landing .feature { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 24px; text-align: center; box-shadow: var(--shadow-sm); }
.landing .feature .icon { width: 48px; height: 48px; border-radius: 12px; background: var(--color-primary-soft); color: var(--color-primary); display: grid; place-items: center; font-size: 24px; margin: 0 auto 12px; }
.landing footer { background: #0f172a; color: #94a3b8; padding: 24px; text-align: center; font-size: 13px; }

/* Misc */
.text-muted { color: var(--color-muted) !important; }
.fw-bold { font-weight: 700; }
.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; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.d-flex { display: flex; } .d-inline-flex { display: inline-flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-grow-1 { flex-grow: 1; }
.text-center { text-align: center; }
.small { font-size: 12px; }
.divider { height: 1px; background: var(--color-border); margin: 16px 0; }

/* Print buttons row */
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

/* Filter bar */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 12px;
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius);
  margin-bottom: 16px; align-items: center;
}
.filter-bar .form-control, .filter-bar .form-select { min-width: 150px; padding: 7px 10px; font-size: 13px; }
.filter-bar .btn { padding: 7px 14px; font-size: 13px; }

/* Notification bell */
.bell { position: relative; }
.bell .dot { position: absolute; top: -4px; left: -4px; background: #dc2626; color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 999px; font-weight: 700; }

.d-none { display: none !important; }
.d-lg-none { display: inline-block; }
@media (min-width: 992px) { .d-lg-none { display: none; } }

/* Empty state */
.empty {
  text-align: center; padding: 48px 24px; color: var(--color-muted);
  background: var(--color-card); border-radius: var(--radius); border: 1px dashed var(--color-border);
}
.empty .emoji { font-size: 48px; opacity: .6; }
.empty h3 { color: var(--color-text); margin: 12px 0 6px; }

/* =====================================================================
   PHASE 5H — Theme + Responsive (added 2026-05-21)
   - Robust dark-mode coverage for inline-styled blocks in views
   - Mobile-first tweaks: tables scroll, smaller padding, touchable buttons
   - Guide page: theme-aware
   - PWA: viewport-safe heights on iOS
   ===================================================================== */

/* Make ALL tables responsive: any wrapped .table-modern overflows horizontally on small screens instead of breaking layout. */
.table-modern { width: 100%; }
@media (max-width: 768px) {
  .table-modern { font-size: 13px; }
  .table-modern thead th, .table-modern tbody td { padding: 8px 6px; }
}

/* Wrap big tables in scrollable container — use this class on parent of any table that doesn't fit small screens. */
.table-scroll-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table-scroll-wrap .table-modern { min-width: 600px; }

/* Filter bar — stack vertically on small screens, full-width controls. */
@media (max-width: 768px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control, .filter-bar .form-select { width: 100%; min-width: 0; }
  .filter-bar .btn { width: 100%; }
}

/* KPI grid: 2 cols on tablet, 1 col on phone (already auto-fit, but force tighter spacing). */
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; gap: 12px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 20px; }
}

/* Card padding tighter on mobile. */
@media (max-width: 600px) {
  .card-soft .card-header { padding: 12px 14px; font-size: 14px; }
  .card-soft .card-body { padding: 14px; }
  .app-main { padding: 12px 14px 40px; }
}

/* Touch-friendly buttons (44x44 minimum on mobile per Apple HIG / Google Material). */
@media (max-width: 600px) {
  .btn { min-height: 40px; padding: 9px 14px; }
  .btn.btn-sm { min-height: 36px; padding: 7px 12px; }
  .form-control, .form-select { min-height: 42px; font-size: 15px; }
  /* Prevent iOS zoom-on-focus by ensuring inputs are >= 16px */
  input, textarea, select { font-size: 16px; }
}

/* Landing page: smaller hero on mobile, stack buttons vertically. */
@media (max-width: 600px) {
  .landing .nav { padding: 12px 14px; flex-wrap: wrap; }
  .landing .hero { padding: 32px 14px 48px; }
  .landing .hero h1 { font-size: 24px; line-height: 1.4; }
  .landing .hero p { font-size: 15px; }
  .landing .hero .cta { flex-direction: column; align-items: stretch; }
  .landing .hero .cta .btn { width: 100%; }
  .landing .features { padding: 36px 14px; }
}

/* Auth pages — smaller on mobile, no padding waste. */
@media (max-width: 600px) {
  .auth-shell { padding: 16px; }
  .auth-card { padding: 22px; border-radius: 12px; }
  .auth-card h1 { font-size: 18px; }
}

/* Top bar: smaller on mobile. */
@media (max-width: 600px) {
  .app-topbar .title { font-size: 18px; }
  .app-topbar { padding: 12px 14px; }
}

/* Form rows -> single column on phones (also handled at 600px earlier; ensure consistent). */
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr !important; }
  .dob-row { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .dob-row .form-select { font-size: 14px; padding: 8px 6px; }
}

/* iOS Safari safe-area: keep buttons above the home-bar. */
@supports (padding: env(safe-area-inset-bottom)) {
  .app-main, .landing .features, .auth-shell {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}

/* ----- Dark mode coverage for inline-styled view fragments ----- */
/* Many views use hard-coded background colors for blocks. The Phase 1 attribute
   selectors covered the most common ones; expand for newer Phase 5 views: */
html[data-theme="dark"] [style*="background:#fafafa"] { background: var(--color-card-2) !important; color: var(--color-text) !important; }
html[data-theme="dark"] [style*="background:#f0f9ff"] { background: #082f49 !important; color: #bae6fd !important; }
html[data-theme="dark"] [style*="border:1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border: 1px solid #e2e8f0"] { border-color: var(--color-border) !important; }
html[data-theme="dark"] [style*="color:#0f172a"],
html[data-theme="dark"] [style*="color: #0f172a"] { color: var(--color-text) !important; }
html[data-theme="dark"] [style*="color:#1f2d3d"],
html[data-theme="dark"] [style*="color: #1f2d3d"] { color: var(--color-text) !important; }
html[data-theme="dark"] [style*="color:#475569"] { color: var(--color-muted) !important; }
html[data-theme="dark"] [style*="background:#0f172a"] { background: var(--color-card) !important; }

/* Guide page (applicant) — uses inline styles for code-like sections; dark mode override. */
html[data-theme="dark"] .guide-wrap { color: var(--color-text); }
html[data-theme="dark"] .guide-wrap h1 { color: #60a5fa; }
html[data-theme="dark"] .guide-wrap h2 { color: #93c5fd; border-color: var(--color-border); }
html[data-theme="dark"] .guide-wrap h3 { color: var(--color-text); }
html[data-theme="dark"] .guide-wrap p,
html[data-theme="dark"] .guide-wrap li { color: var(--color-text); }
html[data-theme="dark"] .guide-wrap .note { background: #082f49; color: #bae6fd; border-right-color: #38bdf8; }
html[data-theme="dark"] .guide-wrap .warn { background: #451a03; color: #fde68a; border-right-color: #f59e0b; }
html[data-theme="dark"] .guide-toc { background: var(--color-card); border-color: var(--color-border); }
html[data-theme="dark"] .guide-toc h3 { color: var(--color-muted); }
html[data-theme="dark"] .guide-toc a { color: #60a5fa; }

/* Admin guide page (system) */
html[data-theme="dark"] .admin-guide { color: var(--color-text); }
html[data-theme="dark"] .admin-guide pre,
html[data-theme="dark"] .admin-guide code { background: var(--color-card-2); color: var(--color-text); border-color: var(--color-border); }
html[data-theme="dark"] .admin-guide .placeholder-tbl th { background: var(--color-table-head); color: var(--color-text); }
html[data-theme="dark"] .admin-guide .placeholder-tbl td { border-color: var(--color-border); color: var(--color-text); }

/* Status badges — better text contrast on dark mode. */
html[data-theme="dark"] .badge-status { font-weight: 700; }

/* Long lists of file names — break long words. */
.attach-list li { word-break: break-word; overflow-wrap: anywhere; }

/* Profession block tags (chips) used on request detail and assignments. */
.staff-chip { display: inline-block; padding: 4px 10px; border-radius: 16px; background: var(--color-primary-soft); color: var(--color-primary); font-size: 12px; font-weight: 600; margin: 2px; transition: transform .15s ease, box-shadow .15s ease; }
.staff-chip:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(29,78,216,.15); }
html[data-theme="dark"] .staff-chip { background: rgba(96,165,250,0.15); color: #93c5fd; }

/* =====================================================================
   PHASE 6 — UI Polish (added 2026-05-21)
   - Smooth transitions everywhere
   - Card hover lifts, button micro-press
   - Focus rings, status badge pulse, form animations
   - Smooth scrolling, improved typography hierarchy
   ===================================================================== */

html { scroll-behavior: smooth; }

/* Global motion defaults */
.btn { transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease, color .15s ease, border-color .15s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(29, 78, 216, .15); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.btn-primary:hover { box-shadow: 0 6px 14px rgba(29, 78, 216, .35); }

/* Card hover lift — soft and subtle */
.card-soft { transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease; }
.card-soft:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15, 23, 42, .08), 0 4px 10px rgba(15, 23, 42, .04); }
html[data-theme="dark"] .card-soft:hover { box-shadow: 0 10px 28px rgba(0,0,0,.5), 0 4px 10px rgba(0,0,0,.4); }

/* KPI cards — animated counter feel */
.kpi { transition: transform .2s ease, box-shadow .2s ease; cursor: default; }
.kpi:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(15,23,42,.08); }
.kpi .value { background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-theme="dark"] .kpi .value { background: linear-gradient(135deg, #60a5fa 0%, #93c5fd 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Form inputs — animated focus ring */
.form-control, .form-select, textarea.form-control {
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.form-control:focus, .form-select:focus, textarea.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .15);
  outline: none;
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] textarea.form-control:focus {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .25);
}

/* Status badge pulse for pending states */
@keyframes pulse-soft {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 83, 9, .35); }
  50%      { box-shadow: 0 0 0 6px rgba(180, 83, 9, 0); }
}
.badge-status.bg-yellow-lt { animation: pulse-soft 2.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .badge-status.bg-yellow-lt { animation: none; }
  html { scroll-behavior: auto; }
  .btn, .card-soft, .kpi { transition: none; }
  .btn:hover, .card-soft:hover, .kpi:hover { transform: none; }
}

/* Timeline — soft fade-in as user reads */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.timeline-item { animation: fade-up .4s ease both; }
.timeline-item:nth-child(2) { animation-delay: .05s; }
.timeline-item:nth-child(3) { animation-delay: .10s; }
.timeline-item:nth-child(4) { animation-delay: .15s; }
.timeline-item:nth-child(5) { animation-delay: .20s; }
.timeline-item:nth-child(n+6) { animation-delay: .25s; }

/* Flash message slide-in */
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.alert-success, .alert-info, .alert-warn, .alert-danger { animation: slide-down .35s ease-out; }

/* Tables — smoother hover */
.table-modern tbody tr { transition: background-color .12s ease; }
.table-modern tbody tr:hover { background: var(--color-table-hover); }

/* Nav items in sidebar — better hover */
.app-sidebar a.nav-item { transition: background-color .15s ease, color .15s ease, padding-right .15s ease; }
.app-sidebar a.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; padding-right: 16px; }

/* Landing page hero — bolder gradient + subtle animation */
.landing { background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 50%, #2563eb 100%); }
.landing .hero h1 { background: linear-gradient(135deg, #ffffff 0%, #dbeafe 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.landing .feature { transition: transform .25s ease, box-shadow .25s ease, border-color .2s ease; }
.landing .feature:hover { transform: translateY(-6px); box-shadow: 0 18px 36px rgba(15,23,42,.12); border-color: var(--color-primary); }
.landing .feature .icon { transition: transform .25s ease; }
.landing .feature:hover .icon { transform: scale(1.1) rotate(-3deg); }

/* Empty-state emoji bounce */
@keyframes gentle-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.empty .emoji { animation: gentle-bounce 2.5s ease-in-out infinite; }

/* Brand title weight + tracking */
.app-sidebar .brand .title, .auth-card .brand .title { letter-spacing: -.01em; }

/* Smooth links underline */
a { transition: color .15s ease; }

/* Floating action vibe for primary buttons */
.btn-primary, .btn-success {
  background-image: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  border: none;
}
.btn-primary:hover { filter: brightness(1.08); }
html[data-theme="dark"] .btn-primary {
  background-image: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/* Section dividers with subtle gradient */
.divider { background: linear-gradient(90deg, transparent, var(--color-border) 20%, var(--color-border) 80%, transparent); }

/* Better quote-style note boxes */
.guide-wrap .note, .guide-wrap .warn,
.admin-guide .note, .admin-guide .warn, .admin-guide .success {
  position: relative;
  border-radius: 8px;
  padding: 12px 18px 12px 14px;
}
.guide-wrap .note { box-shadow: 0 2px 8px rgba(29,78,216,.08); }
.guide-wrap .warn { box-shadow: 0 2px 8px rgba(217,119,6,.10); }

/* Loading skeleton (utility, opt-in via class .skel) */
@keyframes skel-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skel {
  background: linear-gradient(90deg, var(--color-border) 0%, var(--color-card-2) 50%, var(--color-border) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s linear infinite;
  color: transparent !important;
  border-radius: 6px;
  user-select: none;
}

/* Tighter line-height on body text for clarity */
body { line-height: 1.6; }

/* QR code containers in views — subtle border + hover */
img[src^="data:image/png"], img[src*="qr"] {
  transition: transform .2s ease;
}
.card-soft img[src^="data:image/png"]:hover { transform: scale(1.05); }

/* Subtle separators between filter-bar items */
.filter-bar { gap: 10px; }
.filter-bar > * { transition: opacity .2s ease; }

/* Mobile burger animation */
.sidebar-burger { transition: transform .2s ease; }
.app-shell.has-sidebar-open .sidebar-burger { transform: rotate(90deg); }

/* Better blockquote-like body text styling on request show */
[style*="white-space:pre-wrap"][style*="background:#f8fafc"],
[style*="white-space: pre-wrap"][style*="background: #f8fafc"] {
  border-right: 3px solid var(--color-primary) !important;
  border-radius: 6px;
}
html[data-theme="dark"] [style*="white-space:pre-wrap"][style*="background"] {
  border-right-color: #60a5fa !important;
}

/* =====================================================================
   PHASE 7 — Mobile/responsive polish (added 2026-06-01)
   Fixes overlapping columns on mobile staff queue + cramped data tables
   ===================================================================== */

/* All large data tables become horizontally scrollable on small screens. */
@media (max-width: 768px) {
  .table-modern {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 13px;
  }
  .table-modern thead, .table-modern tbody, .table-modern tr {
    display: table;
    width: 100%;
    table-layout: auto;
  }
  .table-modern td, .table-modern th {
    padding: 8px 10px;
    line-height: 1.4;
    vertical-align: top;
  }
  /* Override the white-space:nowrap from <td style="..."> for the action column. */
  .table-modern td[style*="nowrap"] {
    white-space: nowrap !important;
  }
}

/* Filter bars stack on narrow screens. */
@media (max-width: 600px) {
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-bar > * { width: 100%; max-width: none !important; }
  .filter-bar select, .filter-bar input { font-size: 14px; }
  .filter-bar .btn { width: 100%; }
}

/* KPI grid: 2 cols on small, 1 col on very small. */
@media (max-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
  .kpi .value { font-size: 22px; }
}

/* Form rows collapse to single column on small. */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr !important; gap: 12px !important; }
  .form-row > * { width: 100%; }
}

/* Sidebar mobile drawer — uses the SAME classes the JS toggles
   (.app-sidebar.open + .app-shell.has-sidebar-open) so the hamburger works. */
@media (max-width: 900px) {
  .app-sidebar {
    position: fixed; top: 0; right: -86%; bottom: 0; left: auto;
    width: 82%; max-width: 320px;
    z-index: 1050;
    transition: right .25s ease;
    box-shadow: -4px 0 24px rgba(0,0,0,.25);
    overflow-y: auto;
  }
  .app-sidebar.open { right: 0; }
  .app-shell.has-sidebar-open::before {
    content: '';
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 1040;
  }
  .sidebar-burger { display: inline-flex !important; }
  .app-main { padding: 16px !important; }
}

/* Long Arabic content in cards/inputs doesn't overflow horizontally */
.card-soft .card-body, .card-soft .card-header {
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* Staff chip wrapping in small screens */
@media (max-width: 600px) {
  .staff-chip { font-size: 11px; padding: 3px 7px; }
}

/* Buttons: bigger touch target on mobile */
@media (max-width: 600px) {
  .btn { min-height: 38px; padding: 8px 14px; }
  .btn-sm { min-height: 32px; padding: 6px 12px; }
}

/* Status badges stay readable */
.badge-status {
  white-space: nowrap;
  display: inline-block;
  max-width: 100%;
}

/* Iframe / image overflow protection */
.card-body img, .card-body iframe { max-width: 100%; height: auto; }

/* Modal-ish flash messages: full width on mobile */
@media (max-width: 600px) {
  .alert { font-size: 14px; padding: 10px 12px; }
}

/* Print-template editor + admin guide: prevent overflow on mobile */
@media (max-width: 760px) {
  pre, code { font-size: 12px; overflow-x: auto; max-width: 100%; }
  textarea.form-control { min-height: 120px; font-size: 13px; }
}

/* =====================================================================
   PHASE 7 fix A1 — Aggressive mobile fixes for dashboard overlap
   ===================================================================== */

/* On mobile (≤900px), the sidebar is a drawer; the main content gets the FULL width
   without any reserved space for the sidebar. Fixes overlap on /app/dashboard. */
@media (max-width: 900px) {
  .app-shell { display: block !important; }  /* override any grid/flex with sidebar column */
  .app-shell .app-main {
    width: 100% !important;
    margin: 0 !important;
    padding: 12px 14px !important;
    max-width: 100% !important;
  }
  /* Topbar (hamburger area) becomes a sticky header */
  .app-topbar {
    position: sticky; top: 0; z-index: 999;
    background: var(--color-bg); border-bottom: 1px solid var(--color-border);
    padding: 10px 14px;
  }
  /* Page title + subtitle fit cleanly */
  .page-header h1, .page-header h2 { font-size: 18px !important; line-height: 1.4; }
  .page-header .text-muted { font-size: 12px !important; }
  /* Cards on dashboard never overflow horizontally */
  .card-soft { margin-bottom: 12px; max-width: 100%; }
  .card-soft .card-header { font-size: 14px; padding: 10px 14px; }
  .card-soft .card-body  { padding: 12px 14px; }
}

/* Ensure no horizontal scroll on the page itself */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  * { max-width: 100vw; }
  table { table-layout: auto; }
}

/* Mobile-friendly KPI grid (already in Phase 7 fix #9 but reinforce) */
@media (max-width: 900px) {
  .kpi-grid { display: grid; grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .kpi { padding: 12px !important; }
  .kpi .value { font-size: 24px !important; line-height: 1.1; }
  .kpi .label { font-size: 11px !important; }
  .kpi .icon  { font-size: 18px !important; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
}

/* Sticky bottom safe area on iPhone */
@media (max-width: 900px) {
  .app-main { padding-bottom: max(24px, env(safe-area-inset-bottom, 24px)) !important; }
}

/* =====================================================================
   PHASE 8 — Mobile form-control reliability + labeled date fields
   (date inputs were rendering as confusing empty boxes on phones)
   ===================================================================== */

/* Labeled date filter: a small caption above the native date box so it is
   never mistaken for an empty/broken dropdown on mobile. */
.date-field { display: inline-flex; flex-direction: column; gap: 3px; vertical-align: top; }
.date-field-label { font-size: 11px; font-weight: 700; color: var(--color-muted); }
.date-field .form-control { max-width: 170px; }
input[type="date"].form-control { min-height: 42px; background: var(--color-input, #fff); }
@media (max-width: 600px) {
  .date-field { width: 100%; }
  .date-field .form-control { max-width: none; width: 100%; }
}

/* Guarantee the OS-native dropdown on every device — never let a select get an
   appearance:none with no replacement (the classic "tap highlights, list never
   opens" bug). Force native menulist + a comfortable touch target. */
select.form-select, select.form-control {
  -webkit-appearance: menulist !important;
  -moz-appearance: menulist !important;
  appearance: menulist !important;
  background-image: none;
}
@media (max-width: 768px) {
  select.form-select, select.form-control,
  input.form-control, input[type="date"].form-control {
    min-height: 46px; font-size: 16px;  /* >=16px stops iOS zoom; 46px easy tap */
  }
  /* 3-select date rows (DOB / appointment) stay 3 columns and readable */
  .dob-row { grid-template-columns: 1fr 1fr 1fr !important; gap: 6px !important; }
  .dob-row .form-select { padding: 10px 6px; min-width: 0; }
}

/* =====================================================================
   PHASE 8 — Live notifications: fly-in toasts + bell ring + list page
   ===================================================================== */
.toast-wrap {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 4000; display: flex; flex-direction: column; gap: 10px; align-items: center;
  width: min(440px, calc(100% - 24px)); pointer-events: none;
}
.toast-notif {
  pointer-events: auto; width: 100%; display: flex; gap: 10px; align-items: flex-start;
  background: var(--color-card); border: 1px solid var(--color-border);
  border-inline-start: 4px solid var(--color-primary); border-radius: 12px;
  box-shadow: 0 10px 34px rgba(15,23,42,.20); padding: 12px 14px; position: relative; cursor: pointer;
  transform: translateY(-26px) scale(.97); opacity: 0;
  transition: transform .35s cubic-bezier(.2,.85,.25,1), opacity .3s;
}
.toast-notif.in  { transform: translateY(0) scale(1); opacity: 1; }
.toast-notif.out { transform: translateY(-18px) scale(.96); opacity: 0; }
.toast-ic   { font-size: 18px; line-height: 1.4; }
.toast-main { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; font-size: 14px; color: var(--color-text); }
.toast-body  { font-size: 12.5px; color: var(--color-muted); margin-top: 3px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.toast-close { position: absolute; top: 6px; inset-inline-start: 8px; background: none; border: none;
  font-size: 20px; line-height: 1; color: var(--color-muted); cursor: pointer; padding: 0 4px; }
.toast-close:hover { color: var(--color-text); }

@keyframes bell-ring {
  0%,100% { transform: rotate(0); }
  12% { transform: rotate(16deg); } 24% { transform: rotate(-13deg); }
  36% { transform: rotate(10deg); } 48% { transform: rotate(-8deg); } 60% { transform: rotate(4deg); }
}
.bell.ring { animation: bell-ring .7s ease; display: inline-block; }

/* Notifications list page */
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif-item { display: flex; gap: 12px; align-items: flex-start; background: var(--color-card);
  border: 1px solid var(--color-border); border-inline-start: 4px solid var(--color-primary);
  border-radius: 12px; padding: 12px 14px; transition: opacity .2s, border-color .2s; }
.notif-item.is-read { border-inline-start-color: var(--color-border); opacity: .7; }
.notif-item .notif-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--color-primary); margin-top: 6px; flex: none; }
.notif-item.is-read .notif-dot { background: var(--color-border); }
.notif-item .notif-main { flex: 1; min-width: 0; }
.notif-item .notif-title { font-weight: 700; font-size: 14.5px; }
.notif-item .notif-body  { color: var(--color-muted); font-size: 13px; margin-top: 3px; line-height: 1.6; }
.notif-item .notif-time  { color: var(--color-muted); font-size: 11.5px; margin-top: 4px; }
.notif-item .notif-actions { display: flex; flex-direction: column; gap: 6px; flex: none; align-items: stretch; }
@media (max-width: 600px) { .notif-item { flex-wrap: wrap; } .notif-item .notif-actions { flex-direction: row; width: 100%; } }

/* ---- Bell dropdown panel (social-app style popup) ---- */
.notif-panel {
  position: fixed; z-index: 4500; background: var(--color-card); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: 14px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(15,23,42,.28); display: flex; flex-direction: column;
  max-height: min(70vh, 540px);
  opacity: 0; transform: translateY(-10px) scale(.98); pointer-events: none;
  transition: opacity .18s ease, transform .2s cubic-bezier(.2,.85,.25,1);
}
.notif-panel.open { opacity: 1; transform: none; pointer-events: auto; }
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.notif-panel-title { font-weight: 800; font-size: 15px; }
.notif-panel-count { display: inline-block; background: var(--color-primary); color: #fff; font-size: 11px;
  font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-inline-start: 6px; vertical-align: middle; }
.notif-panel-readall { background: none; border: none; color: var(--color-primary); font-weight: 700;
  font-size: 12.5px; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.notif-panel-readall:hover { background: var(--color-primary-soft); }
.notif-panel-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.notif-panel-empty { padding: 34px 16px; text-align: center; color: var(--color-muted); font-size: 13px; line-height: 2; }
.notif-row { display: flex; gap: 11px; align-items: flex-start; padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid var(--color-border); text-decoration: none; color: inherit; position: relative;
  transition: background .14s ease; }
.notif-row:last-child { border-bottom: 0; }
.notif-row:hover { background: var(--color-table-hover); }
.notif-row.is-unread { background: var(--color-primary-soft); }
.notif-row.is-unread:hover { filter: brightness(.98); }
.notif-row-ic { font-size: 17px; line-height: 1.5; flex: none; }
.notif-row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.notif-row-title { font-weight: 700; font-size: 13.5px; color: var(--color-text); }
.notif-row-body { font-size: 12.5px; color: var(--color-muted); margin-top: 2px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-row-time { font-size: 11px; color: var(--color-muted); margin-top: 4px; }
.notif-row-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--color-primary); flex: none; margin-top: 6px; }
.notif-panel-foot { padding: 10px 16px; text-align: center; border-top: 1px solid var(--color-border); }
.notif-panel-foot a { color: var(--color-primary); font-weight: 700; font-size: 13px; text-decoration: none; }
.notif-panel-foot a:hover { text-decoration: underline; }
.bell { cursor: pointer; }

/* =====================================================================
   PHASE 8 — Tasteful motion (entrance + micro-interactions).
   Fully disabled for users who prefer reduced motion.
   ===================================================================== */
@media (prefers-reduced-motion: no-preference) {
  @keyframes mjj-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
  .card-soft, .form-card, .auth-card, .kpi, .empty, .filter-bar { animation: mjj-fade-up .38s ease both; }
  /* Gentle stagger for KPI cards so the dashboard feels alive on load */
  .kpi-grid .kpi:nth-child(1) { animation-delay: .02s; }
  .kpi-grid .kpi:nth-child(2) { animation-delay: .08s; }
  .kpi-grid .kpi:nth-child(3) { animation-delay: .14s; }
  .kpi-grid .kpi:nth-child(4) { animation-delay: .20s; }

  .kpi      { transition: transform .16s ease, box-shadow .16s ease; }
  .kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
  .card-soft { transition: box-shadow .2s ease, transform .16s ease; }
  .nav-item  { transition: background .15s ease, padding .15s ease; }
  .btn       { transition: background .15s, transform .06s, box-shadow .15s, filter .15s; }
  .btn:hover { filter: brightness(1.04); }
  .btn:active { transform: translateY(1px) scale(.99); }
  .table-modern tbody tr { transition: background .12s ease; }
  .bell { transition: transform .12s ease; }
  .bell:hover { transform: scale(1.08); }
  .badge-status { transition: transform .12s ease; }

  /* Row highlight when a new request/notification just arrived (opt-in via .just-in) */
  @keyframes mjj-flash { 0% { background: var(--color-primary-soft); } 100% { background: transparent; } }
  .just-in { animation: mjj-flash 1.6s ease; }
}

/* =====================================================================
   PWA install affordance — persistent, re-approachable (not the browser's
   one-shot mini-infobar). Small floating pill, bottom-start on RTL so it
   never covers the mobile nav toggle which lives at the opposite side.
   ===================================================================== */
.pwa-install-btn {
  position: fixed;
  inset-inline-start: 16px;
  bottom: 16px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  cursor: pointer;
}
.pwa-install-btn:hover { filter: brightness(1.06); }

/* Push button stacks above the install button (both can be visible at once —
   installed but notifications not yet enabled). Distinct color so the two
   affordances read as separate actions, not duplicates. */
.pwa-push-btn {
  bottom: 66px;
  background: #0f172a;
}
html[data-theme="dark"] .pwa-push-btn { background: #334155; }

.pwa-ios-hint {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 23, 42, .45);
  padding: 16px;
}
.pwa-ios-hint-box {
  position: relative;
  background: var(--color-card);
  color: var(--color-text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  line-height: 1.7;
}
.pwa-ios-hint-close {
  position: absolute;
  top: 8px;
  inset-inline-end: 10px;
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--color-muted);
  cursor: pointer;
}

/* =====================================================================
   PUBLIC INFORMATIONAL SITE (stream 3 — the content pages that replaced
   the legacy PHP 5.6 MJ CMS on citizens.uoanbar.edu.iq).
   All colors come from the theme tokens so dark mode works for free.
   ===================================================================== */
.pub-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.pub-head-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.pub-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--color-text); }
.pub-brand img { width: 42px; height: 42px; object-fit: contain; }
.pub-brand-title { display: block; font-weight: 700; font-size: 15px; }
.pub-brand-sub { display: block; font-size: 11px; color: var(--color-muted); }

.pub-burger {
  display: none;
  margin-inline-start: auto;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-text);
  border-radius: 8px;
  font-size: 18px;
  padding: 6px 12px;
  cursor: pointer;
}

.pub-nav { display: flex; align-items: center; gap: 16px; margin-inline-start: auto; flex-wrap: wrap; }
.pub-nav-list { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.pub-nav-item { position: relative; }
.pub-nav-link {
  display: inline-block;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.pub-nav-link:hover { background: var(--color-primary-soft); color: var(--color-primary); }
.pub-nav-link.is-active { color: var(--color-primary); background: var(--color-primary-soft); }
.pub-nav-link .caret { font-size: 10px; opacity: .7; }

.pub-subnav {
  position: absolute;
  inset-inline-start: 0;
  top: 100%;
  min-width: 230px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  list-style: none;
  margin: 4px 0 0;
  display: none;
}
.pub-nav-item.has-children:hover > .pub-subnav,
.pub-nav-item.has-children:focus-within > .pub-subnav { display: block; }
.pub-subnav a {
  display: block;
  padding: 9px 12px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--color-text);
  font-size: 13.5px;
}
.pub-subnav a:hover { background: var(--color-primary-soft); color: var(--color-primary); }
.pub-subnav a.is-active { color: var(--color-primary); font-weight: 700; }

.pub-actions { display: flex; align-items: center; gap: 8px; }

/* --- content --- */
.pub-main { max-width: 1000px; margin: 0 auto; padding: 24px 16px 60px; }
.pub-crumbs { font-size: 13px; color: var(--color-muted); margin-bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.pub-crumbs a { color: var(--color-primary); text-decoration: none; }
.pub-crumbs a:hover { text-decoration: underline; }
.pub-crumbs .current { color: var(--color-muted); }

.pub-article {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px;
}
.pub-article > h1 {
  font-size: 26px;
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text);
}

/* Typography for imported legacy content — the source HTML carries no styling
   of its own any more, so everything is driven from here. */
.pub-body { line-height: 1.95; font-size: 15px; color: var(--color-text); }
.pub-body p { margin: 0 0 14px; }
.pub-body h1, .pub-body h2, .pub-body h3, .pub-body h4 {
  color: var(--color-text); margin: 24px 0 10px; line-height: 1.5;
}
.pub-body h2 { font-size: 19px; }
.pub-body h3 { font-size: 16.5px; }
.pub-body ul, .pub-body ol { margin: 0 0 14px; padding-inline-start: 24px; }
.pub-body li { margin-bottom: 7px; }
.pub-body a { color: var(--color-primary); }
.pub-body strong, .pub-body b { font-weight: 700; }
.pub-body blockquote {
  margin: 14px 0;
  padding: 10px 16px;
  border-inline-start: 3px solid var(--color-primary);
  background: var(--color-primary-soft);
  border-radius: 8px;
}
.pub-table-scroll { overflow-x: auto; margin: 18px 0; -webkit-overflow-scrolling: touch; }
.pub-body table {
  border-collapse: collapse;
  width: 100%;
  min-width: 460px;
  font-size: 14px;
  background: var(--color-card);
}
.pub-body th, .pub-body td {
  border: 1px solid var(--color-border);
  padding: 9px 12px;
  text-align: start;
  vertical-align: top;
}
.pub-body thead th, .pub-body tr:first-child td {
  background: var(--color-table-head);
  font-weight: 700;
  color: var(--color-text);
}
.pub-body tbody tr:hover td { background: var(--color-table-hover); }
.pub-body table p { margin: 0; }

/* --- child-page cards (section index) --- */
.pub-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.pub-card {
  display: block;
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card-2);
  text-decoration: none;
  color: var(--color-text);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.pub-card:hover {
  transform: translateY(-3px);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}
.pub-card h3 { margin: 0 0 8px; font-size: 16px; }
.pub-card-go { font-size: 13px; color: var(--color-primary); font-weight: 600; }

/* --- inline CTA --- */
.pub-cta {
  margin-top: 24px;
  padding: 26px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
  color: #fff;
  text-align: center;
}
.pub-cta h2 { margin: 0 0 8px; font-size: 20px; color: #fff; }
.pub-cta p { margin: 0 0 16px; color: rgba(255,255,255,.9); font-size: 14.5px; }
.pub-cta-actions { display: inline-flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pub-cta-actions .btn-ghost {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
}

/* --- footer --- */
.pub-foot { background: #0f172a; color: #94a3b8; margin-top: 40px; }
.pub-foot-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 36px 16px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 26px;
}
.pub-foot-title { color: #fff; font-weight: 700; margin-bottom: 10px; font-size: 14.5px; }
.pub-foot-col p { font-size: 13px; line-height: 1.8; margin: 0; }
.pub-foot-col ul { list-style: none; margin: 0; padding: 0; }
.pub-foot-col li { margin-bottom: 7px; }
.pub-foot-col a { color: #94a3b8; text-decoration: none; font-size: 13px; }
.pub-foot-col a:hover { color: #fff; text-decoration: underline; }
.pub-foot-bar {
  border-top: 1px solid rgba(148,163,184,.2);
  padding: 14px 16px;
  text-align: center;
  font-size: 12.5px;
}

/* Department page links in the landing hero nav (dark gradient background). */
.landing-link {
  color: rgba(255,255,255,.88);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 7px;
  white-space: nowrap;
}
.landing-link:hover { background: rgba(255,255,255,.14); color: #fff; }

@media (max-width: 860px) {
  .pub-burger { display: inline-block; }
  .pub-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 10px;
  }
  .pub-nav.open { display: flex; }
  .pub-nav-list { flex-direction: column; align-items: stretch; gap: 0; }
  .pub-subnav {
    position: static;
    display: block;
    border: none;
    box-shadow: none;
    padding: 0 0 6px;
    margin: 0;
    background: transparent;
    min-width: 0;
  }
  .pub-subnav a { padding-inline-start: 26px; font-size: 13px; color: var(--color-muted); }
  .pub-actions { justify-content: flex-start; flex-wrap: wrap; }
  .pub-article { padding: 18px; }
  .pub-article > h1 { font-size: 21px; }
}
