/* 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: #fff; 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; }
