/* QAMS custom UI - no external frameworks */

:root {
  /* Cairo University brand */
  --cu-burgundy:  #8A0000;
  --cu-navy:      #313168;
  --cu-parchment: #EFEACC;
  --cu-sky:       #9FDCEF;

  /* Application tokens */
  --navy:       #313168;   /* sidebar background */
  --navy-light: #3D3D7A;   /* sidebar hover tint */
  --white:      #FFFFFF;
  --accent:     #8A0000;   /* primary action colour — burgundy */
  --success:    #16A34A;
  --warning:    #D97706;
  --danger:     #DC2626;
  --grey:       #6B7280;
  --bg:         #F3F4F6;
  --border:     #E5E7EB;
  --text:       #111827;
  --text-muted: #6B7280;
  --sidebar-width:  240px;
  --topbar-height:  60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

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

h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 18px; }

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  color: #cbd5e1;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  transition: transform 0.2s ease;
  z-index: 100;
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  font-weight: 700;
}
.sidebar-brand .sidebar-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: #fff;
  object-fit: contain;
  padding: 2px;
}

.sidebar nav { padding: 12px 0; }
.sidebar .nav-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: #8896b3; padding: 16px 16px 6px;
}
.sidebar a.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: 13px; color: #cbd5e1;
  border-left: 3px solid transparent;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.07); text-decoration: none; }
.sidebar a.nav-link.active {
  background: rgba(139,0,0,0.22); color: #fff; border-left-color: var(--accent);
}

.main-area { margin-left: var(--sidebar-width); flex: 1; min-width: 0; transition: margin-left 0.2s ease; }
.main-area.full { margin-left: 0; }

.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
}
.topbar .page-title { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text); }

.bell-wrap { position: relative; cursor: pointer; }
.bell-badge {
  position: absolute; top: -6px; right: -8px;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 10px; padding: 1px 5px; min-width: 16px; text-align: center;
}
.notif-dropdown {
  position: absolute; right: 0; top: 36px; width: 320px; max-height: 400px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  display: none; z-index: 200;
}
.notif-dropdown.open { display: block; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-item.unread { background: #FFF8F8; font-weight: 600; border-left: 2px solid var(--accent); }
.notif-item .notif-time { font-size: 11px; color: var(--text-muted); }
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.notif-header button { font-size: 12px; }

.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}

.content { padding: 24px; }

/* ---------- Cards ---------- */
.card {
  background: var(--white); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px; margin-bottom: 20px;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data-table th { background: #F9FAFB; font-weight: 600; color: var(--text-muted); }
table.data-table tbody tr:nth-child(odd) { background: #FAFAFB; }
table.data-table tbody tr:hover { background: #F1F5F9; }
.table-actions { display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 5px 8px;
  cursor: pointer; font-size: 12px; color: var(--text);
}
.icon-btn:hover { background: #F3F4F6; }
.icon-btn.danger { color: var(--danger); border-color: #fecaca; }
.icon-btn.danger:hover { background: #fef2f2; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,0,0,0.12); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

/* ---------- Searchable select (type-to-filter combobox) ---------- */
.searchable-select { position: relative; }
.searchable-select-options {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 220px;
  overflow-y: auto;
  z-index: 150;
}
.searchable-select-options.open { display: block; }
.searchable-select-option { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.searchable-select-option:hover, .searchable-select-option.active { background: #FFF0F0; }
.searchable-select-option.hidden { display: none; }
.searchable-select-empty { padding: 8px 12px; font-size: 13px; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 6px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #6B0000; text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #F3F4F6; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-grey { background: #E5E7EB; color: #374151; }
.badge-green { background: #DCFCE7; color: #166534; }
.badge-amber { background: #FEF3C7; color: #92400E; }
.badge-red { background: #FEE2E2; color: #991B1B; }
.badge-blue { background: #DBEAFE; color: #1E40AF; }

/* ---------- Alerts / flash ---------- */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #DCFCE7; color: #166534; }
.alert-error { background: #FEE2E2; color: #991B1B; }
.alert-info { background: #DBEAFE; color: #1E40AF; }
.alert-warning { background: #FEF3C7; color: #92400E; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a, .pagination span {
  padding: 6px 11px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text);
}
.pagination a:hover { background: #F3F4F6; text-decoration: none; }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* ---------- Progress ---------- */
.progress-bar-track { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar-fill { background: var(--accent); height: 100%; }
.progress-bar-fill.complete { background: var(--success); }
.progress-bar-fill.warning { background: var(--warning); }

/* ---------- Topbar refinements ---------- */
.topbar { border-bottom: 1px solid var(--border); }
.topbar .page-title { font-size: 16px; font-weight: 600; color: var(--text); }

/* ---------- Sidebar refinements ---------- */
.sidebar-brand { letter-spacing: 0.02em; }
.sidebar .nav-section-title { color: rgba(255,255,255,0.38); }
.sidebar-manual { border-top: 1px solid rgba(255,255,255,0.08); margin-top: 4px; padding: 6px 0; }

/* ---------- Focus ring (a11y) ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Misc ---------- */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.filters-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-end; }
.deadline-warning { color: var(--warning); font-weight: 600; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
}
