/* ============================================
   UK Study Consultancy – Professional Admin
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active-bg: #dc2626;
  --sidebar-active-text: #fff;
  --primary: #0f172a;
  --primary-soft: #1e293b;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.08), 0 4px 10px -5px rgba(0,0,0,.04);
  --focus-ring: 0 0 0 3px rgba(15,23,42,.12);
}

* { box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.9375rem;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ----- Sidebar ----- */
.dash-sidebar {
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  z-index: 1030;
  box-shadow: 4px 0 24px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
}
.dash-sidebar .brand {
  padding: 1.5rem 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-weight: 700;
  font-size: 1.125rem;
  color: #fff;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.dash-sidebar .brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #fff;
  flex-shrink: 0;
}
.dash-sidebar .nav {
  padding: 1.25rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.dash-sidebar .nav-link.logout { margin-top: auto; }
.dash-sidebar .nav-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,.4);
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}
.dash-sidebar .nav-link {
  color: rgba(255,255,255,.78);
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 2px;
  font-weight: 500;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: background .2s, color .2s;
  border-left: 3px solid transparent;
}
.dash-sidebar .nav-link .bi { font-size: 1.2rem; opacity: .88; width: 1.25rem; text-align: center; }
.dash-sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.dash-sidebar .nav-link.active {
  background: rgba(220,38,38,.15);
  color: #fff;
  border-left-color: var(--sidebar-active-bg);
}
.dash-sidebar .nav-link.logout { margin-top: auto; color: rgba(255,255,255,.6); }
.dash-sidebar .nav-link.logout:hover { color: #fca5a5; background: rgba(220,38,38,.1); }

/* CMS dropdown in sidebar */
.dash-cms-details { margin-bottom: 2px; }
.dash-cms-details summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.9rem;
  color: rgba(255,255,255,.78);
  border-left: 3px solid transparent;
  transition: background .2s, color .2s;
}
.dash-cms-details summary::-webkit-details-marker { display: none; }
.dash-cms-details summary .bi-chevron-down {
  margin-left: auto;
  font-size: 0.75rem;
  opacity: .7;
  transition: transform .2s;
}
.dash-cms-details[open] summary .bi-chevron-down { transform: rotate(-180deg); }
.dash-cms-details summary:hover { background: var(--sidebar-hover); color: #fff; }
.dash-cms-details summary.active { background: rgba(220,38,38,.15); color: #fff; border-left-color: var(--sidebar-active-bg); }
.dash-cms-details .nav-sublinks {
  padding: 0.35rem 0 0.5rem 1.5rem;
  border-left: 1px solid rgba(255,255,255,.1);
  margin-left: 0.75rem;
  max-height: 60vh;
  overflow-y: auto;
}
.dash-cms-details .nav-sublink {
  display: block;
  padding: 0.4rem 0.6rem;
  color: rgba(255,255,255,.65);
  font-size: 0.8rem;
  border-radius: 6px;
  text-decoration: none;
  margin-bottom: 1px;
  transition: background .15s, color .15s;
}
.dash-cms-details .nav-sublink:hover { background: var(--sidebar-hover); color: #fff; }
.dash-cms-details .nav-sublink.active { color: #fca5a5; font-weight: 500; }

/* ----- Main ----- */
.dash-main {
  margin-left: 280px;
  min-height: 100vh;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
}

/* ----- Top bar ----- */
.dash-topbar {
  background: var(--surface);
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  min-height: 72px;
}
.dash-topbar .page-title {
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.02em;
}
.dash-topbar .page-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0;
}
.dash-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.dash-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}
.dash-user .bi-person-circle { font-size: 1.6rem; color: var(--text-muted); }

/* ----- Content ----- */
.dash-content { padding: 1.75rem; flex: 1; }

/* ----- Stat cards ----- */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  height: 100%;
  transition: box-shadow .2s, border-color .2s, transform .2s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--stat-accent, #6366f1);
  border-radius: 4px 0 0 4px;
}
.stat-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
  background: var(--stat-icon-bg, rgba(99,102,241,.12));
  color: var(--stat-icon-color, #6366f1);
}
.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.stat-card .stat-value {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.stat-card.stat-primary { --stat-accent: #0f172a; --stat-icon-bg: rgba(15,23,42,.08); --stat-icon-color: #0f172a; }
.stat-card.stat-success { --stat-accent: #059669; --stat-icon-bg: rgba(5,150,105,.12); --stat-icon-color: #059669; }
.stat-card.stat-warning { --stat-accent: #d97706; --stat-icon-bg: rgba(217,119,6,.12); --stat-icon-color: #d97706; }
.stat-card.stat-info { --stat-accent: #0284c7; --stat-icon-bg: rgba(2,132,199,.12); --stat-icon-color: #0284c7; }

/* ----- Cards ----- */
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.dash-card .card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 1.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
}
.dash-card .card-body { padding: 1.5rem; }

/* ----- Tables ----- */
.dash-table {
  margin: 0;
  font-size: 0.875rem;
}
.dash-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.dash-table tbody td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}
.dash-table tbody tr:last-child td { border-bottom: 0; }
.dash-table tbody tr:hover { background: #fafafa; }
.dash-table .badge {
  font-weight: 600;
  font-size: 0.6875rem;
  padding: 0.4em 0.75em;
  letter-spacing: 0.02em;
}

/* ----- Buttons ----- */
.btn-dash-primary {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius);
  border: none;
  font-size: 0.875rem;
  transition: background .2s, box-shadow .2s;
}
.btn-dash-primary:hover { background: var(--primary-soft); color: #fff; box-shadow: var(--shadow); }
.btn-dash-outline {
  background: transparent;
  color: var(--text);
  font-weight: 500;
  border: 1px solid var(--border);
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.btn-dash-outline:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-dash-danger {
  background: #dc2626;
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  padding: 0.55rem 1.15rem;
  font-size: 0.875rem;
}
.btn-dash-danger:hover { background: #b91c1c; color: #fff; }

/* ----- Form controls (global in dashboard) ----- */
.dash-content .form-control,
.dash-content .form-select {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
}
.dash-content .form-control:focus,
.dash-content .form-select:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
.dash-content .form-label { font-weight: 500; color: var(--text); }
.input-group-text {
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-muted);
}
.input-group .form-control { border-radius: 0 var(--radius) var(--radius) 0; }
.input-group .form-control:focus { z-index: 1; }

/* ============================================
   Login page
   ============================================ */
.dash-login-wrap {
  min-height: 100vh;
  background: var(--sidebar-bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(220,38,38,.15), transparent),
    linear-gradient(180deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
}
.dash-login-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  opacity: .5;
}
.dash-login-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.05);
  overflow: hidden;
  max-width: 440px;
  width: 100%;
  position: relative;
  z-index: 1;
}
.dash-login-card .login-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  padding: 2rem 2rem 1.75rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.dash-login-card .login-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 20px rgba(220,38,38,.35);
}
.dash-login-card .login-header h1 {
  font-size: 1.375rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}
.dash-login-card .login-header p {
  margin: 0;
  font-size: 0.875rem;
  opacity: .85;
  color: rgba(255,255,255,.9);
}
.dash-login-card .card-body { padding: 2rem 2rem 2.25rem; }
.dash-login-card .form-label {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
}
.dash-login-card .form-control {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  font-size: 0.9375rem;
}
.dash-login-card .form-control:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
.dash-login-card .input-group-text {
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0 1rem;
}
.dash-login-card .input-group .form-control {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: 0;
}
.dash-login-card .btn-login {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius);
  border: none;
  width: 100%;
  font-size: 0.9375rem;
  transition: background .2s, box-shadow .2s;
}
.dash-login-card .btn-login:hover {
  background: var(--primary-soft);
  color: #fff;
  box-shadow: var(--shadow);
}
.dash-login-card .login-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.dash-login-card .login-footer .small {
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.dash-login-card .login-footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8125rem;
}
.dash-login-card .login-footer a:hover { color: var(--primary); }

/* ============================================
   Responsive – all screens (dashboard)
   ============================================ */

/* Mobile menu toggle button (injected by JS) */
.dash-menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1040;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.4rem;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.dash-menu-toggle:hover { background: var(--primary-soft); color: #fff; }
.dash-menu-toggle:focus { outline: none; box-shadow: var(--focus-ring); }

/* Overlay when sidebar open on mobile */
.dash-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1025;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
body.dash-menu-open .dash-overlay {
  display: block;
  opacity: 1;
  pointer-events: auto;
}
body.dash-menu-open { overflow: hidden; }

/* Tablet and below: sidebar becomes overlay drawer */
@media (max-width: 991.98px) {
  .dash-menu-toggle { display: flex; }
  .dash-sidebar {
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform .25s ease, box-shadow .25s ease;
    max-height: 100vh;
    overflow-y: auto;
  }
  body.dash-menu-open .dash-sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.2);
  }
  .dash-main { margin-left: 0; }
  .dash-topbar {
    padding: 0.85rem 1rem 0.85rem 4rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .dash-topbar .page-title { font-size: 1.15rem; }
  .dash-topbar .page-subtitle { font-size: 0.75rem; }
  .dash-user {
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
  }
  .dash-user span { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dash-content { padding: 1rem; }
  .dash-card .card-header {
    padding: 0.9rem 1rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .dash-card .card-body { padding: 1rem; }
  .dash-table thead th,
  .dash-table tbody td { padding: 0.75rem 0.6rem; font-size: 0.8125rem; }
  .stat-card { padding: 1.25rem; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .stat-card .stat-icon { width: 44px; height: 44px; font-size: 1.25rem; }
}

/* Table wrapper: horizontal scroll on small screens */
.dash-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -1rem;
  padding: 0 1rem;
}
@media (min-width: 992px) {
  .dash-table-wrap { margin: 0; padding: 0; }
}

/* Small mobile */
@media (max-width: 575.98px) {
  .dash-menu-toggle { top: 0.75rem; left: 0.75rem; width: 40px; height: 40px; font-size: 1.25rem; }
  .dash-topbar { padding-left: 3.5rem; padding-right: 0.75rem; }
  .dash-topbar .d-flex.gap-2 { flex-direction: column; align-items: flex-start !important; }
  .dash-user span { display: none; }
  .dash-content { padding: 0.75rem; }
  .dash-table-wrap { margin: 0 -0.75rem; padding: 0 0.75rem; }
  .dash-table thead th,
  .dash-table tbody td { padding: 0.5rem 0.4rem; font-size: 0.75rem; white-space: nowrap; }
  .dash-table .btn { padding: 0.35rem 0.5rem; font-size: 0.75rem; }
  .dash-table .btn .bi { font-size: 0.9em; }
  .dash-table .d-flex.gap-1 { flex-wrap: wrap; gap: 0.25rem !important; }
  .stat-card .stat-value { font-size: 1.35rem; }
  .stat-card .stat-label { font-size: 0.75rem; }
  .dash-card .card-header .d-flex { flex-direction: column; align-items: flex-start !important; }
  .dash-card .card-header .btn { width: 100%; justify-content: center; }
  .modal-dialog { margin: 0.5rem; max-width: calc(100% - 1rem); }
  .modal-content { border-radius: var(--radius); }
  .modal-header, .modal-body { padding: 1rem; }
  .form-label, .form-control, .form-select { font-size: 0.875rem; }
}

/* Login page responsive */
@media (max-width: 575.98px) {
  .dash-login-wrap { padding: 1rem; }
  .dash-login-card .login-header { padding: 1.5rem 1rem; }
  .dash-login-card .login-header h1 { font-size: 1.2rem; }
  .dash-login-card .card-body { padding: 1.25rem 1rem; }
  .dash-login-card .btn-login { padding: 0.75rem; }
}
@media (max-width: 391px) {
  .dash-login-card .login-logo { width: 48px; height: 48px; font-size: 1.5rem; }
}
