/* ============================================
   STUDYVAULT — Design Tokens
   ============================================ */
:root {
  /* Color */
  --navy-950: #0a1a30;
  --navy-900: #0f2547;
  --navy-800: #18335f;
  --navy-100: #e8edf5;
  --gray-50:  #f7f8fa;
  --gray-100: #eef0f3;
  --gray-200: #e1e4e9;
  --gray-400: #9aa3b2;
  --gray-600: #5b6472;
  --ink:      #16202e;
  --white:    #ffffff;
  --gold:     #c8a045;
  --success:  #1f8a5a;
  --danger:   #c0392b;

  /* Type */
  --font-display: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Layout */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 37, 71, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 37, 71, 0.08);
  --shadow-lg: 0 20px 48px rgba(15, 37, 71, 0.14);
  --container: 1180px;
  --nav-h: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }

ul { list-style: none; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--navy-900);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.section-head h2 { font-size: clamp(1.5rem, 2.5vw, 2rem); }

.section-sub { color: var(--gray-600); font-size: 0.95rem; margin-top: 6px; }

/* ============================================
   Navbar
   ============================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gray-200);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--navy-900);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(155deg, var(--navy-900), var(--navy-800));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark svg { width: 18px; height: 18px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--gray-600);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-links a:hover { background: var(--gray-100); color: var(--navy-900); }
.nav-links a.active { background: var(--navy-900); color: var(--white); }

.nav-actions { display: flex; align-items: center; gap: 10px; }

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
}

.nav-toggle svg { width: 22px; height: 22px; color: var(--navy-900); }

@media (max-width: 880px) {
  .nav-links {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 4px;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { width: 100%; }
  .nav-toggle { display: flex; }
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--navy-900);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--navy-800); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.btn-ghost {
  background: var(--white);
  color: var(--navy-900);
  border: 1.5px solid var(--gray-200);
}
.btn-ghost:hover { border-color: var(--navy-900); }

.btn-gold {
  background: var(--gold);
  color: var(--navy-950);
}
.btn-gold:hover { filter: brightness(1.06); transform: translateY(-1px); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(192, 57, 43, 0.08); }

.btn-sm { padding: 8px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ============================================
   Hero
   ============================================ */
.hero {
  position: relative;
  padding: 88px 0 96px;
  background: radial-gradient(120% 140% at 85% -10%, var(--navy-800) 0%, var(--navy-900) 45%, var(--navy-950) 100%);
  color: var(--white);
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent 70%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.hero .eyebrow { color: var(--gold); }

.hero h1 {
  color: var(--white);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  margin: 14px 0 18px;
}

.hero h1 span { color: var(--gold); }

.hero p {
  color: var(--navy-100);
  font-size: 1.08rem;
  max-width: 520px;
  margin-bottom: 32px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.hero .btn-ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.25);
  color: var(--white);
}
.hero .btn-ghost:hover { border-color: var(--gold); background: rgba(255,255,255,0.06); }

.hero-stats {
  display: flex;
  gap: 36px;
  flex-wrap: wrap;
}

.hero-stat .num {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--white);
}
.hero-stat .label {
  font-size: 0.8rem;
  color: var(--navy-100);
  opacity: 0.75;
}

/* Search bar */
.search-bar {
  position: relative;
  max-width: 560px;
  margin-top: 8px;
}

.search-bar input {
  width: 100%;
  padding: 15px 18px 15px 48px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(255,255,255,0.98);
  font-size: 0.96rem;
  font-family: inherit;
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

.search-bar input:focus { outline: 2px solid var(--gold); }

.search-bar .icon {
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--gray-600);
}

.search-bar.on-light input { box-shadow: var(--shadow-sm); border: 1.5px solid var(--gray-200); }

/* ============================================
   Sections
   ============================================ */
.section { padding: 72px 0; }
.section-alt { background: var(--white); border-top: 1px solid var(--gray-200); border-bottom: 1px solid var(--gray-200); }

/* ============================================
   Material Cards
   ============================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

@media (max-width: 980px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .card-grid { grid-template-columns: 1fr; } }

.material-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.material-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--navy-800);
}

.card-index {
  position: absolute;
  top: 18px;
  right: 18px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-400);
  letter-spacing: 0.05em;
}

.card-top { display: flex; align-items: flex-start; gap: 12px; padding-right: 28px; }

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--navy-100);
  color: var(--navy-900);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-icon svg { width: 20px; height: 20px; }

.card-title { font-size: 1.04rem; font-weight: 600; color: var(--navy-900); margin-bottom: 2px; }

.subject-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--navy-100);
  color: var(--navy-800);
}

.card-desc { color: var(--gray-600); font-size: 0.89rem; flex-grow: 1; }

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-100);
  padding-top: 12px;
}

.card-meta .uploader { display: flex; align-items: center; gap: 6px; color: var(--gray-600); font-weight: 500; }

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--navy-800);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-actions { display: flex; gap: 8px; margin-top: 4px; }
.card-actions .btn { flex: 1; }

/* ============================================
   CTA banner
   ============================================ */
.cta-banner {
  background: var(--navy-900);
  border-radius: var(--radius-lg);
  padding: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  color: var(--white);
  position: relative;
  overflow: hidden;
}

.cta-banner::after {
  content: '';
  position: absolute;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(200,160,69,0.18), transparent 70%);
  right: -80px; top: -100px;
}

.cta-banner h3 { color: var(--white); font-size: 1.5rem; margin-bottom: 8px; }
.cta-banner p { color: var(--navy-100); max-width: 420px; }
.cta-banner .actions { display: flex; gap: 12px; flex-wrap: wrap; position: relative; z-index: 1; }

/* ============================================
   Footer
   ============================================ */
footer {
  background: var(--navy-950);
  color: var(--navy-100);
  padding: 56px 0 28px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  padding-bottom: 36px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

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

.footer-col h4 { color: var(--white); font-size: 0.85rem; letter-spacing: 0.05em; margin-bottom: 14px; }
.footer-col a, .footer-col p { color: var(--navy-100); opacity: 0.75; font-size: 0.88rem; }
.footer-col ul { display: flex; flex-direction: column; gap: 10px; }
.footer-col a:hover { opacity: 1; color: var(--gold); }
.footer-brand .brand { color: var(--white); margin-bottom: 10px; }
.footer-brand p { max-width: 280px; opacity: 0.6; }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 22px;
  font-size: 0.8rem;
  opacity: 0.55;
  flex-wrap: wrap;
  gap: 10px;
}

/* ============================================
   Page header (non-home pages)
   ============================================ */
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 44px 0 32px;
}

.page-header h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
.page-header p { color: var(--gray-600); margin-top: 8px; max-width: 540px; }

/* ============================================
   Filters / toolbar
   ============================================ */
.toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.toolbar .search-bar { flex: 1; min-width: 220px; margin-top: 0; }

select.filter-select {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink);
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--gray-600);
}

.empty-state svg { width: 56px; height: 56px; color: var(--gray-400); margin: 0 auto 16px; }
.empty-state h3 { color: var(--navy-900); margin-bottom: 6px; }

/* ============================================
   Forms
   ============================================ */
.form-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 640px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
}

.form-group { margin-bottom: 22px; }

.form-group label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--navy-900);
  margin-bottom: 7px;
}

.form-group label .req { color: var(--danger); }

.form-group .hint { font-size: 0.78rem; color: var(--gray-400); margin-top: 5px; }

.form-control {
  width: 100%;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  font-family: inherit;
  font-size: 0.94rem;
  background: var(--gray-50);
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.form-control:focus {
  border-color: var(--navy-800);
  background: var(--white);
  outline: none;
}

.form-control.invalid { border-color: var(--danger); background: #fdf2f1; }

textarea.form-control { resize: vertical; min-height: 100px; }

.error-msg { color: var(--danger); font-size: 0.8rem; margin-top: 6px; display: none; }
.error-msg.show { display: block; }

.form-actions { display: flex; gap: 12px; margin-top: 8px; }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 26, 48, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 100%;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }

.modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--navy-100);
  color: var(--navy-900);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.modal-icon svg { width: 26px; height: 26px; }

.modal-box h3 { font-size: 1.25rem; margin-bottom: 10px; }
.modal-box p { color: var(--gray-600); font-size: 0.93rem; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.modal-close {
  position: absolute;
  top: 18px; right: 18px;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-400);
}
.modal-close:hover { background: var(--gray-100); color: var(--ink); }
.modal-box { position: relative; }

/* ============================================
   Toasts
   ============================================ */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 600;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--navy-950);
  color: var(--white);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  min-width: 260px;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ============================================
   Loader
   ============================================ */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9999;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loader-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--navy-900);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-mark 1.1s ease-in-out infinite;
}
.loader-mark svg { width: 24px; height: 24px; color: var(--gold); }

@keyframes pulse-mark {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.9); opacity: 0.7; }
}

.loader-overlay span { font-size: 0.85rem; color: var(--gray-600); font-weight: 500; }

.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 37%, var(--gray-100) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ============================================
   Chatbot
   ============================================ */
.chat-wrap {
  max-width: 720px;
  margin: 0 auto;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat-head {
  background: var(--navy-900);
  color: var(--white);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); }
.chat-head h3 { color: var(--white); font-size: 1rem; margin: 0; }
.chat-head span { font-size: 0.78rem; color: var(--navy-100); opacity: 0.8; }

.chat-body {
  height: 420px;
  overflow-y: auto;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--gray-50);
}

.msg { display: flex; gap: 10px; max-width: 85%; }
.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: var(--white);
}
.msg.bot .msg-avatar { background: var(--navy-900); }
.msg.user .msg-avatar { background: var(--gold); color: var(--navy-950); }

.msg-bubble {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.89rem;
  line-height: 1.5;
}
.msg.bot .msg-bubble { background: var(--white); border: 1px solid var(--gray-200); color: var(--ink); }
.msg.user .msg-bubble { background: var(--navy-900); color: var(--white); }

.chat-suggestions {
  padding: 14px 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--gray-200);
  font-size: 0.8rem;
  color: var(--navy-900);
  font-weight: 500;
  transition: all 0.15s ease;
}
.chip:hover { background: var(--navy-900); color: var(--white); border-color: var(--navy-900); }

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

.chat-input-row input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--gray-200);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--gray-50);
}
.chat-input-row input:focus { border-color: var(--navy-800); outline: none; background: var(--white); }

.chat-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--navy-900);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.chat-send:hover { background: var(--navy-800); }
.chat-send svg { width: 18px; height: 18px; }

.typing-dots { display: flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gray-400);
  animation: bounce-dot 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ============================================
   Utilities
   ============================================ */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--navy-950);
  font-size: 0.7rem;
  font-weight: 700;
}
