/* =============================================
   OPM Bursary Portal - Responsive Styles
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Root Tokens ─────────────────────────────── */
:root {
  --blue-deep:    #38003C;   /* ink — deep plum */
  --blue-mid:     #5B0F66;   /* ink-2 — mid plum */
  --blue-light:   #970038;   /* deep magenta — secondary */
  --gold:         #04C7CC;   /* cyan accent (was gold) */
  --gold-bright:  #1ED2DB;   /* bright cyan */
  --gold-pale:    #DEFBFD;   /* pale cyan */
  --cream:        #F4F4F6;   /* cool canvas (was warm cream) */
  --surface:      #ffffff;
  --border:       #E2E1E8;
  --text-primary: #15101C;
  --text-muted:   #666477;
  --shadow-sm:    0 1px 4px rgba(56,0,60,0.08);
  --shadow-md:    0 4px 20px rgba(56,0,60,0.12);
  --shadow-lg:    0 12px 40px rgba(56,0,60,0.16);
  --radius:       12px;
  --radius-lg:    18px;
  --transition:   0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(4,199,202,0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(91,15,102,0.06) 0%, transparent 60%);
}

h1, h2, h3, h4 {
  font-family: 'Oswald', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

img, video { max-width: 100%; height: auto; }

/* ── Responsive Typography ───────────────────── */
@media (max-width: 480px) {
  html { font-size: 13px; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.35rem; }
  h3 { font-size: 1.15rem; }
  h4 { font-size: 1rem; }
}

@media (min-width: 481px) and (max-width: 768px) {
  html { font-size: 14px; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  html { font-size: 15px; }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
}

@media (min-width: 1025px) {
  html { font-size: 16px; }
  h1 { font-size: 2.25rem; }
  h2 { font-size: 2rem; }
}

/* ── Gradients ───────────────────────────────── */
.gradient-hero {
  background: linear-gradient(140deg, var(--blue-deep) 0%, var(--blue-mid) 55%, #1C0020 100%);
  position: relative;
  overflow: hidden;
}

.gradient-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 70% -30%, rgba(4,199,202,0.16) 0%, transparent 55%),
    radial-gradient(ellipse at -10% 110%, rgba(151,0,56,0.35) 0%, transparent 50%);
  pointer-events: none;
}

nav.gradient-hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-bright), var(--gold), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

/* ── Transparent / Glass Navigation ──────────────
   Frosted-glass nav that stays airy at the top of the
   page and gently solidifies once the user scrolls,
   so text underneath always stays readable. */
#public-nav {
  background: rgba(56, 0, 60, 0.48) !important;
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: none !important;
  transition: background var(--transition), box-shadow var(--transition), backdrop-filter var(--transition);
}

#public-nav::before { opacity: 0.5; transition: opacity var(--transition); }

#public-nav.nav-scrolled {
  background: rgba(28, 0, 30, 0.90) !important;
  box-shadow: 0 8px 30px rgba(56,0,60,0.25) !important;
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
}

#public-nav.nav-scrolled::before { opacity: 1; }
#public-nav.nav-scrolled::after  { opacity: 0.6; }

/* Admin/staff areas keep a fully solid header — clarity over flourish */
.admin-header {
  background: var(--blue-deep);
}

.gradient-card {
  background: linear-gradient(145deg, #ffffff 0%, #F4F2F7 100%);
}

/* ── Navigation ──────────────────────────────── */
nav {
  padding: 0.75rem 1rem;
}

/* Mobile nav adjustments */
@media (max-width: 768px) {
  nav { padding: 0.5rem 0.75rem; }

  /* Make the nav container flex and not overflow */
  nav .max-w-7xl {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Logo text wrapping on tiny screens */
  nav h1 { font-size: 0.95rem; }
  nav p  { font-size: 0.65rem; }

  /* Mobile menu dropdown */
  #mobile-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(24, 0, 26, 0.97);
    backdrop-filter: blur(20px) saturate(1.6);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  }

  #mobile-menu a {
    display: block;
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
  }

  #mobile-menu a:last-child { border-bottom: none; }
  #mobile-menu a:hover { color: var(--gold-bright); }
}

@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
}

/* ── Navigation Links ────────────────────────── */
.nav-link {
  position: relative;
  font-weight: 600 !important;
  font-size: 0.8rem !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.8) !important;
  transition: color var(--transition);
}

.nav-link:hover { color: #fff !important; }

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0;
  width: 0; height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  border-radius: 2px;
  transition: width var(--transition);
}

.nav-link:hover::after,
.nav-link.active::after { width: 100%; }

/* ── Buttons ─────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: var(--blue-deep) !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  font-size: 0.85rem !important;
  letter-spacing: 0.03em;
  border-radius: 6px;
  padding: 0.75rem 1.5rem;
  box-shadow: 0 2px 8px rgba(4,199,202,0.35), 0 1px 2px rgba(0,0,0,0.08);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 100%);
  pointer-events: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #5FE8EE 0%, var(--gold-bright) 100%);
  box-shadow: 0 4px 16px rgba(4,199,202,0.45), 0 1px 3px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(4,199,202,0.3);
}

@media (max-width: 768px) {
  .btn-primary {
    padding: 0.875rem 1.25rem;
    width: 100%;
    font-size: 1rem;
  }
}

/* ── Forms ───────────────────────────────────── */
.form-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .form-container {
    padding: 1rem 0.75rem;
    max-width: 100%;
  }
}

input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

/* Prevent iOS zoom on focus */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
    padding: 0.75rem;
  }
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(4,199,202,0.15);
}

input::placeholder, textarea::placeholder {
  color: #a8a29e;
  font-weight: 300;
}

/* ── Cards / Grid ────────────────────────────── */
.card-grid {
  display: grid;
  gap: 1.5rem;
}

@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr; gap: 0.75rem; }
}

@media (min-width: 481px) and (max-width: 768px) {
  .card-grid { grid-template-columns: 1fr; gap: 1rem; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1025px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.doc-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(4,199,202,0.35);
}

.stat-card {
  background: var(--surface);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle, rgba(4,199,202,0.08) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Portal Welcome Banner (grid-cols-3 fix) ─── */
@media (max-width: 480px) {
  /* Welcome banners that use grid-cols-3 become a single column */
  .grid.grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }

  /* Student info row inside banner */
  [class*="grid-cols-3"] > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }

  [class*="grid-cols-3"] > div:last-child {
    border-bottom: none;
  }
}

@media (min-width: 481px) and (max-width: 640px) {
  .grid.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.25rem !important;
    font-size: 0.75rem;
  }
}

/* ── Tables ──────────────────────────────────── */
.data-table {
  width: 100%;
  overflow-x: auto;
  display: block;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

thead th {
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--blue-deep), var(--blue-mid)) !important;
  color: var(--gold-bright) !important;
  border-bottom: none;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--gold-pale); }

tbody td {
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .data-table { font-size: 0.8rem; }

  .data-table th,
  .data-table td {
    padding: 0.5rem 0.4rem;
    white-space: nowrap;
  }

  thead th { font-size: 0.625rem; }
}

/* ── Status Badges ───────────────────────────── */
.status-pending, .status-review, .status-approved, .status-rejected {
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 20px;
  display: inline-block;
}

.status-pending {
  background: linear-gradient(135deg, #fef9ec, #fef3c7);
  color: #92400e;
  border: 1px solid #f6d860;
}

.status-review {
  background: linear-gradient(135deg, #f4f4f5, #e4e4e7);
  color: #3f3f46;
  border: 1px solid #a1a1aa;
}

.status-approved {
  background: linear-gradient(135deg, #f0fdf4, #d1fae5);
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.status-rejected {
  background: linear-gradient(135deg, #fff5f5, #fee2e2);
  color: #991b1b;
  border: 1px solid #fca5a5;
}

@media (max-width: 480px) {
  .status-pending, .status-review, .status-approved, .status-rejected {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
    letter-spacing: 0.04em;
  }
}

/* ── Sidebar ─────────────────────────────────────
   Mobile-first: the off-canvas drawer is the DEFAULT
   state for every screen size. Desktop's static,
   always-visible sidebar is an explicit upgrade below
   (min-width: 769px) — never the other way around.
   This way, if a device misreports its width or a
   browser's "Desktop site" mode kicks in, the safe
   mobile drawer is still what renders, not a squeezed
   desktop layout. ─────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 80vw;
  max-width: 280px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--transition);
  z-index: 50;
}

.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}

.sidebar-overlay.active { display: block; }

.admin-layout {
  flex-direction: column;
}

.admin-main {
  width: 100%;
  padding: 1rem 0.75rem;
}

/* ── Desktop upgrade: sidebar becomes a normal,
   always-visible column instead of a drawer ────── */
@media (min-width: 768px) {
  .sidebar {
    position: static;
    height: auto;
    width: 260px;
    max-width: none;
    overflow-y: visible;
    transform: none;
  }

  .sidebar-overlay,
  .sidebar-overlay.active {
    display: none !important;
  }

  .admin-layout {
    flex-direction: row;
  }

  .admin-main {
    width: auto;
    padding: 0;
  }
}

.sidebar-item {
  transition: var(--transition);
  border-radius: 8px;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.sidebar-item:hover {
  background: linear-gradient(135deg, var(--blue-mid), var(--blue-light));
  color: white;
  padding-left: 1.25rem;
}

.sidebar-item.active {
  background: linear-gradient(135deg, var(--blue-deep), var(--blue-mid));
  color: white;
  box-shadow: 0 2px 10px rgba(74,15,18,0.25);
}

.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--gold-bright);
  border-radius: 0 2px 2px 0;
}

/* ── Upload Zone ─────────────────────────────── */
.upload-zone {
  border: 2px dashed #C7C5D6;
  border-radius: var(--radius);
  background: linear-gradient(145deg, #FAFAFB, #EFEFF3);
  transition: var(--transition);
  position: relative;
  padding: 2rem;
}

@media (max-width: 768px) {
  .upload-zone {
    padding: 1.25rem 0.875rem;
  }

  .upload-zone i.text-3xl { font-size: 1.5rem; }
  .upload-zone p { font-size: 0.85rem; }
}

.upload-zone:hover {
  border-color: var(--gold);
  background: linear-gradient(145deg, #F2FDFE, #E0FAFB);
}

.upload-zone.dragover {
  border-color: var(--gold-bright);
  background: linear-gradient(145deg, #EAFCFD, #D5F8F9);
  box-shadow: 0 0 0 4px rgba(4,199,202,0.15);
}

/* ── Progress Bar ────────────────────────────── */
.progress-bar {
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-bright) 50%, var(--gold) 100%);
  background-size: 200% 100%;
  animation: shimmerProgress 2s linear infinite;
  border-radius: 99px;
}

@keyframes shimmerProgress {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ── Animations ──────────────────────────────── */
.fade-in {
  animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide-in {
  animation: slideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Timeline ────────────────────────────────── */
.timeline-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(4,199,202,0.22);
}

.timeline-line {
  width: 2px;
  background: linear-gradient(180deg, var(--gold-pale), var(--border));
}

@media (max-width: 480px) {
  /* Timeline steps stack more compactly */
  .timeline-dot { width: 10px; height: 10px; }
}

/* ── Glass Effect ────────────────────────────── */
.glass {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gold-pale), #C7C5D6);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ── Selection ───────────────────────────────── */
::selection {
  background: rgba(4,199,202,0.25);
  color: var(--blue-deep);
}

/* ── Footer ──────────────────────────────────── */
footer.gradient-hero {
  border-top: 1px solid rgba(255,255,255,0.08);
}

footer h3, footer h4 {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

footer a { transition: color var(--transition); }
footer a:hover { color: var(--gold-bright) !important; }

/* Footer grid collapses on mobile */
@media (max-width: 640px) {
  footer .grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 1.5rem !important;
  }

  footer .grid > div:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 400px) {
  footer .grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Utility ─────────────────────────────────── */
.shadow-sm  { box-shadow: var(--shadow-sm) !important; }
.shadow-md  { box-shadow: var(--shadow-md) !important; }
.shadow-lg  { box-shadow: var(--shadow-lg) !important; }
.rounded-lg { border-radius: var(--radius) !important; }
.rounded-xl { border-radius: var(--radius-lg) !important; }

/* ── Mobile Touch & Spacing Improvements ─────── */
@media (max-width: 768px) {
  * { -webkit-tap-highlight-color: transparent; }

  /* Comfortable touch targets */
  button, a, .btn-primary, .nav-link, .sidebar-item {
    min-height: 44px;
  }

  /* Page padding so content doesn't touch edges */
  .min-h-screen.py-8 {
    padding-top: 1.25rem !important;
    padding-bottom: 1.25rem !important;
  }

  .px-4 { padding-left: 0.875rem !important; padding-right: 0.875rem !important; }

  /* Cards inside portals */
  .rounded-2xl.shadow-xl.p-6,
  .rounded-2xl.shadow-xl.p-8 {
    padding: 1.25rem 1rem !important;
    border-radius: 1rem !important;
  }

  /* Prevent content overflow */
  body { overflow-x: hidden; }
  .max-w-3xl, .max-w-4xl, .max-w-2xl {
    padding-left: 0.875rem;
    padding-right: 0.875rem;
  }
}

/* ── Very small phones (iPhone SE etc) ───────── */
@media (max-width: 375px) {
  html { font-size: 12px; }

  .rounded-2xl.shadow-xl {
    padding: 1rem 0.75rem !important;
  }

  .btn-primary { font-size: 0.9rem; }
}