/* ============================================================
   StudyMate — Design System
   Fresh SaaS: dark sidebar · soft lavender bg · gradient cards
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Brand */
  --indigo:         #6366F1;
  --indigo-light:   #EEF2FF;
  --indigo-dark:    #4338CA;
  --violet:         #8B5CF6;
  --violet-light:   #F5F3FF;
  --violet-dark:    #6D28D9;
  --pink:           #EC4899;
  --pink-light:     #FDF2F8;
  --pink-dark:      #BE185D;
  --emerald:        #10B981;
  --emerald-light:  #ECFDF5;
  --amber:          #F59E0B;
  --amber-light:    #FFFBEB;
  --sky:            #0EA5E9;
  --sky-light:      #F0F9FF;
  --rose:           #F43F5E;

  /* Sidebar */
  --sb-from:        #1E1B4B;
  --sb-to:          #2D2A6B;
  --sb-text:        rgba(255,255,255,0.65);
  --sb-text-active: #ffffff;
  --sb-active-bg:   rgba(255,255,255,0.12);
  --sb-hover-bg:    rgba(255,255,255,0.06);
  --sb-border:      rgba(255,255,255,0.08);
  --sb-width:       260px;

  /* Surfaces */
  --bg:             #F4F5FF;
  --bg-2:           #ECEEFF;
  --card:           #FFFFFF;
  --card-hover:     #FAFBFF;
  --border:         #E8EAFF;
  --border-2:       #D1D5DB;

  /* Text */
  --text:           #0F172A;
  --text-mid:       #475569;
  --text-light:     #94A3B8;
  --text-xlight:    #CBD5E1;

  /* Shadows */
  --shadow-xs:      0 1px 2px rgba(99,102,241,.06);
  --shadow-sm:      0 2px 8px rgba(99,102,241,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 4px 20px rgba(99,102,241,.10), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:      0 12px 40px rgba(99,102,241,.14), 0 4px 8px rgba(0,0,0,.06);
  --shadow-xl:      0 24px 60px rgba(99,102,241,.18);

  /* Shape */
  --r-xs:  6px;
  --r-sm:  10px;
  --r:     14px;
  --r-lg:  20px;
  --r-xl:  28px;
  --r-pill:99px;

  /* Font */
  --font: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
}

/* ─── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

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

/* ─── Sidebar ───────────────────────────────── */
.sidebar {
  width: var(--sb-width);
  background: linear-gradient(160deg, var(--sb-from) 0%, var(--sb-to) 100%);
  position: fixed; top: 0; left: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: transform .3s ease;
}
/* Scrollable inner wrapper — avoids iOS fixed+overflow bug */
.sb-scroll {
  flex: 1 1 0;
  height: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.sb-scroll::-webkit-scrollbar { display: none; }

.sb-logo {
  padding: 24px 22px 20px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--sb-border);
}
.sb-logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}
.sb-logo-icon svg { width: 20px; height: 20px; color: #fff; }
.sb-logo-text { font-size: 1.15rem; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.sb-logo-badge {
  font-size: .6rem; font-weight: 700; letter-spacing: .06em;
  background: linear-gradient(90deg, var(--pink), var(--violet));
  color: #fff; padding: 2px 7px; border-radius: 99px;
  margin-left: 2px; vertical-align: middle;
}

.sb-profile {
  padding: 18px 22px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--sb-border);
}
.sb-profile .ava {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--pink));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .95rem; color: #fff;
  flex-shrink: 0; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.sb-profile .ava img { width: 100%; height: 100%; object-fit: cover; }
.sb-profile .info { flex: 1; min-width: 0; }
.sb-profile .info .name { font-weight: 700; font-size: .88rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-profile .info .role { font-size: .74rem; color: var(--sb-text); margin-top: 1px; }
.sb-profile .info .plan-badge {
  font-size: .65rem; font-weight: 700;
  padding: 1px 6px; border-radius: 99px;
  background: rgba(255,255,255,.15); color: #fff;
  margin-top: 3px; display: inline-block;
}

.sb-section-label {
  padding: 16px 22px 6px;
  font-size: .66rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--sb-text);
  opacity: .7;
}
.sb-nav { padding: 0 12px; }
.sb-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--sb-text); font-size: .86rem; font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer; margin-bottom: 2px;
}
.sb-item:hover { background: var(--sb-hover-bg); color: var(--sb-text-active); }
.sb-item.active {
  background: var(--sb-active-bg);
  color: var(--sb-text-active); font-weight: 700;
}
.sb-item.active .sb-icon { color: var(--indigo); filter: drop-shadow(0 0 6px rgba(99,102,241,.6)); }
.sb-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sb-icon svg { width: 18px; height: 18px; }
.sb-badge {
  margin-left: auto; background: var(--pink);
  color: #fff; font-size: .68rem; font-weight: 800;
  padding: 1px 7px; border-radius: 99px;
  min-width: 18px; text-align: center;
}
.sb-divider { height: 1px; background: var(--sb-border); margin: 8px 12px; }

.sb-footer {
  margin-top: auto;
  padding: 16px 22px;
  border-top: 1px solid var(--sb-border);
  display: flex; align-items: center; gap: 10px;
}
.sb-footer .storage-label { font-size: .72rem; color: var(--sb-text); margin-bottom: 5px; }
.sb-footer .storage-bar { height: 4px; background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; }
.sb-footer .storage-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--indigo), var(--pink)); }

/* ─── Main area ─────────────────────────────── */
.main-wrap { margin-left: var(--sb-width); flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 64px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-menu-btn {
  display: none; background: transparent; border: none;
  color: var(--text-mid); padding: 4px;
}
.topbar-title { font-size: 1.05rem; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.topbar-search {
  display: flex; align-items: center;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--r-pill); padding: 7px 14px; gap: 8px; width: 240px;
  transition: border-color .15s, width .2s;
}
.topbar-search:focus-within { border-color: var(--indigo); width: 300px; }
.topbar-search input { border: none; background: transparent; outline: none; font-size: .84rem; color: var(--text); width: 100%; }
.topbar-search input::placeholder { color: var(--text-light); }
.topbar-search svg { color: var(--text-light); flex-shrink: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: var(--bg); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mid); position: relative; transition: all .15s;
}
.topbar-btn:hover { background: var(--indigo-light); border-color: var(--indigo); color: var(--indigo); }
.topbar-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; background: var(--pink);
  border-radius: 50%; border: 2px solid var(--card);
}

/* ─── Notifications ─────────────────────────── */
.notif-wrap { position: relative; }
.notif-btn  { position: relative; cursor: pointer; background: none; }
.notif-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  background: #EF4444; color: #fff; font-size: .6rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--card); line-height: 1; pointer-events: none;
}
.notif-badge-hidden { display: none; }
.notif-dropdown {
  display: none; position: absolute; top: calc(100% + 10px); right: 0;
  width: 340px; background: var(--card); border: 1.5px solid var(--border);
  border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.12);
  z-index: 999; overflow: hidden;
}
.notif-dropdown.open { display: block; }
.notif-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--border);
}
.notif-header-title { font-size: .85rem; font-weight: 800; color: var(--text); }
.notif-action-btn {
  font-size: .72rem; font-weight: 700; color: var(--indigo); background: none;
  border: none; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: background .15s;
}
.notif-action-btn:hover { background: var(--indigo-light); }
.notif-action-clear { color: #EF4444; }
.notif-action-clear:hover { background: #FEF2F2; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  transition: background .12s; text-decoration: none; cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--indigo-light); }
.notif-item.unread:hover { background: #E0E7FF; }
.notif-icon {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .85rem;
}
.notif-body { flex: 1; min-width: 0; }
.notif-msg  { font-size: .8rem; color: var(--text); line-height: 1.4; word-break: break-word; }
.notif-time { font-size: .7rem; color: var(--text-light); margin-top: 3px; }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--text-light); font-size: .83rem; }
.notif-loading { padding: 24px 16px; text-align: center; color: var(--text-light); font-size: .83rem; }

/* Page body */
.page-body { padding: 28px; flex: 1; }

/* ─── Page header ───────────────────────────── */
.page-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-hd h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.03em; color: var(--text); line-height: 1.2; }
.page-hd p  { font-size: .88rem; color: var(--text-light); margin-top: 4px; }
.page-hd-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ─── Cards ─────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.card:hover { box-shadow: var(--shadow-sm); }
.goal-card[data-open-modal]:hover { box-shadow: 0 4px 20px rgba(99,102,241,.15); transform: translateY(-2px); transition: transform .15s, box-shadow .15s; }
.card-head {
  padding: 20px 22px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: .95rem; font-weight: 700; color: var(--text); }
.card-body  { padding: 20px 22px; }
.card-foot  { padding: 0 22px 20px; display: flex; align-items: center; justify-content: space-between; }

/* Gradient stat card */
.stat-card {
  border-radius: var(--r);
  padding: 22px;
  color: #fff;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card::after {
  content: '';
  position: absolute; top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.stat-card .stat-icon-wrap {
  width: 44px; height: 44px; border-radius: 14px;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-icon-wrap svg { color: #fff; }
.stat-card .stat-val { font-size: 2rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.stat-card .stat-lbl { font-size: .8rem; font-weight: 600; opacity: .85; }
.stat-card .stat-sub { font-size: .74rem; opacity: .7; }

.sc-indigo  { background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%); }
.sc-pink    { background: linear-gradient(135deg, #EC4899 0%, #F43F5E 100%); }
.sc-emerald { background: linear-gradient(135deg, #10B981 0%, #059669 100%); }
.sc-amber   { background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%); }
.sc-sky     { background: linear-gradient(135deg, #0EA5E9 0%, #6366F1 100%); }
.sc-violet  { background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%); }

/* Module card */
.mod-card {
  background: var(--card); border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  transition: transform .2s, box-shadow .2s;
  cursor: pointer;
}
.mod-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.mod-card .mod-icon {
  width: 52px; height: 52px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.mod-card h3 { font-size: 1rem; font-weight: 700; }
.mod-card p  { font-size: .82rem; color: var(--text-light); line-height: 1.5; }
.mod-card .mod-foot {
  margin-top: auto; display: flex; align-items: center;
  justify-content: space-between;
}

/* ─── Stats grid ────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; }
.plain-stat {
  background: var(--card); border-radius: var(--r);
  border: 1px solid var(--border);
  padding: 20px; display: flex; flex-direction: column; gap: 6px;
}
.plain-stat .ps-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.plain-stat .ps-val { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; }
.plain-stat .ps-lbl { font-size: .78rem; color: var(--text-light); font-weight: 500; }

/* ─── Table ─────────────────────────────────── */
.sb-table { width: 100%; border-collapse: collapse; }
.sb-table th {
  text-align: left; padding: 10px 16px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-light);
  border-bottom: 1px solid var(--border);
}
.sb-table td {
  padding: 13px 16px; font-size: .86rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.sb-table tr:last-child td { border-bottom: none; }
.sb-table tr:hover td { background: var(--bg); }

/* ─── Badges ────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: .7rem; font-weight: 700;
}
.badge-indigo  { background: var(--indigo-light); color: var(--indigo-dark); }
.badge-violet  { background: var(--violet-light); color: var(--violet-dark); }
.badge-pink    { background: var(--pink-light);   color: var(--pink-dark); }
.badge-emerald { background: var(--emerald-light);color: #065F46; }
.badge-amber   { background: var(--amber-light);  color: #92400E; }
.badge-sky     { background: var(--sky-light);    color: #0369A1; }
.badge-gray    { background: var(--border);       color: var(--text-mid); }
.badge-red     { background: #FEE2E2;             color: #991B1B; }

/* keep legacy names working */
.badge-purple  { background: var(--violet-light); color: var(--violet-dark); }
.badge-green   { background: var(--emerald-light);color: #065F46; }

/* ─── Buttons ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--r-sm);
  font-size: .87rem; font-weight: 600; font-family: var(--font);
  border: none; cursor: pointer; transition: all .18s; line-height: 1;
}
.btn-primary  { background: linear-gradient(135deg, var(--indigo), var(--violet)); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(99,102,241,.45); opacity: .94; }
.btn-pink     { background: linear-gradient(135deg, var(--pink), var(--rose)); color: #fff; box-shadow: 0 4px 14px rgba(236,72,153,.3); }
.btn-pink:hover { opacity: .92; }
.btn-emerald  { background: linear-gradient(135deg, var(--emerald), #059669); color: #fff; box-shadow: 0 4px 14px rgba(16,185,129,.3); }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text-mid); }
.btn-outline:hover { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-light); }
.btn-ghost    { background: var(--bg); color: var(--text-mid); }
.btn-ghost:hover { background: var(--border); }
.btn-danger   { background: #FEE2E2; color: #DC2626; }
.btn-danger:hover { background: #DC2626; color: #fff; }
.btn-sm  { padding: 6px 14px; font-size: .8rem; border-radius: var(--r-xs); }
.btn-lg  { padding: 13px 28px; font-size: 1rem; }
.btn-icon{ padding: 8px; border-radius: var(--r-sm); }
.btn-pill{ border-radius: var(--r-pill); }
.btn-block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

/* ─── Forms ─────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 6px; font-size: .82rem; font-weight: 600; color: var(--text); }
.form-label .required { color: var(--rose); }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .87rem; color: var(--text);
  background: var(--card); outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.form-control:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-light); }
.form-control::placeholder { color: var(--text-xlight); }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint  { font-size: .76rem; color: var(--text-light); margin-top: 4px; }
.form-error { font-size: .76rem; color: var(--rose); margin-top: 4px; }
.input-wrap { position: relative; }
.input-wrap .form-control { padding-left: 40px; }
.input-wrap .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-light); display: flex; }
.input-wrap-r .form-control { padding-right: 40px; }
.input-wrap-r .input-icon-r { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-light); display: flex; cursor: pointer; }

/* ─── Toggle switch ─────────────────────────── */
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border); border-radius: 99px;
  transition: .2s; cursor: pointer;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--indigo); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ─── Progress ──────────────────────────────── */
.progress { background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .6s ease; }
.progress-xs { height: 4px; }
.progress-sm { height: 6px; }
.progress-md { height: 10px; }
.progress-indigo { background: linear-gradient(90deg, var(--indigo), var(--violet)); }
.progress-pink   { background: linear-gradient(90deg, var(--pink), var(--rose)); }
.progress-green  { background: linear-gradient(90deg, var(--emerald), #059669); }
.progress-amber  { background: linear-gradient(90deg, var(--amber), #D97706); }

/* ─── Avatar ────────────────────────────────── */
.avatar {
  border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; overflow: hidden; object-fit: cover;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.av-xs { width: 26px; height: 26px; font-size: .65rem; }
.av-sm { width: 34px; height: 34px; font-size: .78rem; }
.av-md { width: 44px; height: 44px; font-size: .95rem; }
.av-lg { width: 56px; height: 56px; font-size: 1.15rem; }
.av-xl { width: 72px; height: 72px; font-size: 1.4rem; }
.av-indigo { background: linear-gradient(135deg, var(--indigo), var(--violet)); color: #fff; }
.av-pink   { background: linear-gradient(135deg, var(--pink), var(--rose)); color: #fff; }
.av-emerald{ background: linear-gradient(135deg, var(--emerald), #059669); color: #fff; }
.av-amber  { background: linear-gradient(135deg, var(--amber), #D97706); color: #fff; }
.avatar-group { display: flex; }
.avatar-group .avatar { border: 2px solid var(--card); margin-right: -8px; }

/* ─── Alerts ────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--r-sm); font-size: .87rem; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.alert-error   { background: #FEF2F2; color: #7F1D1D; border-left: 3px solid var(--rose); }
.alert-success { background: var(--emerald-light); color: #064E3B; border-left: 3px solid var(--emerald); }
.alert-info    { background: var(--indigo-light); color: var(--indigo-dark); border-left: 3px solid var(--indigo); }
.alert-warning { background: var(--amber-light); color: #78350F; border-left: 3px solid var(--amber); }

/* ─── Modal ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(6px) saturate(1.2);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .22s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  width: 92%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(24px) scale(.96);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .22s;
  opacity: 0;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); opacity: 1; }
.modal-lottie { display: flex; justify-content: center; padding: 24px 24px 0; }
.modal-lottie lottie-player { width: 110px; height: 110px; }
.modal-head {
  padding: 22px 24px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 800; }
.modal-subtitle { font-size: .84rem; color: var(--text-light); margin-top: 3px; }
.modal-close {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--bg); display: flex; align-items: center;
  justify-content: center; color: var(--text-mid); flex-shrink: 0;
  transition: background .15s;
}
.modal-close:hover { background: var(--border); }
.modal-body  { padding: 20px 24px; }
.modal-foot  { padding: 0 24px 24px; display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Kanban / Priority chips ───────────────── */
.priority-high   { color: var(--rose); background: #FEF2F2; }
.priority-medium { color: var(--amber); background: var(--amber-light); }
.priority-low    { color: var(--emerald); background: var(--emerald-light); }

/* ─── Empty state ───────────────────────────── */
.empty-state {
  text-align: center; padding: 64px 32px;
  color: var(--text-light);
}
.empty-state lottie-player { margin: 0 auto 16px; }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: .88rem; max-width: 360px; margin: 0 auto; }

/* ─── Tabs ──────────────────────────────────── */
.tabs { display: flex; gap: 2px; background: var(--bg); border-radius: var(--r-sm); padding: 4px; border: 1px solid var(--border); }
.tab-btn {
  flex: 1; text-align: center; padding: 8px 16px;
  border-radius: var(--r-xs); font-size: .84rem; font-weight: 600;
  color: var(--text-light); background: transparent;
  border: none; cursor: pointer; transition: all .15s;
}
.tab-btn.active { background: var(--card); color: var(--indigo); box-shadow: var(--shadow-xs); }
.tab-content > * { display: none; }
.tab-content > .active { display: block; }

/* ─── Flashcard flip ────────────────────────── */
.fc-scene { perspective: 1000px; }
.fc-card {
  position: relative; transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4,0,.2,1);
}
.fc-card.flipped { transform: rotateY(180deg); }
.fc-front, .fc-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: var(--r-lg); display: flex;
  align-items: center; justify-content: center; padding: 32px;
  font-size: 1.1rem; font-weight: 600; text-align: center;
}
.fc-back { transform: rotateY(180deg); }

/* ─── Quill editor overrides ────────────────── */
.ql-toolbar.ql-snow { border: 1.5px solid var(--border) !important; border-radius: var(--r-sm) var(--r-sm) 0 0 !important; background: var(--bg); }
.ql-container.ql-snow { border: 1.5px solid var(--border) !important; border-top: none !important; border-radius: 0 0 var(--r-sm) var(--r-sm) !important; min-height: 200px; }
.ql-editor { font-family: var(--font) !important; font-size: .9rem !important; line-height: 1.7 !important; }

/* ─── Kanban board ──────────────────────────── */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; }
.kanban-col { min-width: 280px; flex-shrink: 0; }
.kanban-col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  border: 1px solid var(--border); border-bottom: none;
  font-weight: 700; font-size: .87rem;
}
.kanban-col-head .col-count {
  background: var(--bg); border-radius: 99px;
  font-size: .72rem; padding: 1px 8px; font-weight: 700;
}
.kanban-col-body {
  background: var(--bg); border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 var(--r-sm) var(--r-sm);
  min-height: 200px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.kanban-item {
  background: var(--card); border-radius: var(--r-sm);
  border: 1px solid var(--border); padding: 14px;
  box-shadow: var(--shadow-xs); cursor: grab;
}
.kanban-item:hover { box-shadow: var(--shadow-sm); }

/* ─── Calendar ──────────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 1px; }
.cal-day-hd { text-align: center; font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--text-light); padding: 8px 0; }
.cal-day {
  min-height: 80px; padding: 6px;
  background: var(--card); border: 1px solid var(--border);
  font-size: .78rem;
}
.cal-day.today { background: var(--indigo-light); }
.cal-day.other-month { background: var(--bg); color: var(--text-xlight); }
.cal-day .day-num { font-weight: 700; margin-bottom: 4px; }
.cal-event {
  font-size: .7rem; font-weight: 600; border-radius: 3px;
  padding: 1px 4px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-event-indigo { background: var(--indigo); color: #fff; }
.cal-event-pink   { background: var(--pink);   color: #fff; }
.cal-event-emerald{ background: var(--emerald);color: #fff; }

/* ─── Plan cards ────────────────────────────── */
.plan-card {
  background: var(--card); border-radius: var(--r-lg);
  border: 2px solid var(--border); padding: 28px;
  transition: border-color .2s, box-shadow .2s;
}
.plan-card.featured {
  border-color: var(--indigo);
  box-shadow: 0 8px 30px rgba(99,102,241,.15);
  position: relative;
}
.plan-card.featured::before {
  content: 'Most Popular';
  position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(90deg, var(--indigo), var(--violet));
  color: #fff; font-size: .7rem; font-weight: 800;
  padding: 3px 14px; border-radius: 99px;
  letter-spacing: .05em; text-transform: uppercase;
}
.plan-card .plan-price { font-size: 2.4rem; font-weight: 800; letter-spacing: -.05em; }
.plan-card .plan-period { font-size: .82rem; color: var(--text-light); }
.plan-card ul { margin: 16px 0; display: flex; flex-direction: column; gap: 10px; }
.plan-card li { display: flex; align-items: center; gap: 8px; font-size: .87rem; }
.plan-card li svg { color: var(--emerald); flex-shrink: 0; }

/* ─── Auth layout ───────────────────────────── */
.auth-shell {
  min-height: 100vh; display: flex;
}
.auth-left {
  flex: 1; display: none;
  background: linear-gradient(145deg, var(--sb-from) 0%, var(--sb-to) 60%, #3730A3 100%);
  flex-direction: column; justify-content: center;
  padding: 60px; position: relative; overflow: hidden;
}
@media(min-width:960px){ .auth-left { display: flex; } }
.auth-left::before {
  content: '';
  position: absolute; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(99,102,241,.3) 0%, transparent 70%);
  top: -100px; right: -100px; border-radius: 50%;
}
.auth-left::after {
  content: '';
  position: absolute; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(236,72,153,.2) 0%, transparent 70%);
  bottom: -80px; left: -60px; border-radius: 50%;
}
.auth-left .auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 60px; z-index: 1; }
.auth-left .auth-brand .icon {
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(99,102,241,.4);
}
.auth-left .auth-brand .name { font-size: 1.4rem; font-weight: 800; color: #fff; }
.auth-left .auth-headline { font-size: 2.4rem; font-weight: 800; color: #fff; line-height: 1.2; margin-bottom: 20px; letter-spacing: -.04em; z-index: 1; }
.auth-left .auth-sub { font-size: 1rem; color: rgba(255,255,255,.65); line-height: 1.7; max-width: 380px; z-index: 1; }
.auth-left .auth-features { margin-top: 40px; display: flex; flex-direction: column; gap: 14px; z-index: 1; }
.auth-left .auth-feature { display: flex; align-items: center; gap: 12px; }
.auth-left .auth-feature .f-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.auth-left .auth-feature .f-text { font-size: .88rem; color: rgba(255,255,255,.8); }

.auth-right {
  width: 100%; display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
}
@media(min-width:960px){ .auth-right { width: 480px; flex-shrink: 0; } }
.auth-box { width: 100%; max-width: 400px; }
.auth-box .auth-box-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: 6px; }
.auth-box .auth-box-sub { font-size: .88rem; color: var(--text-light); margin-bottom: 28px; }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  font-size: .78rem; color: var(--text-light); margin: 20px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ─── Layout utilities ──────────────────────── */
.grid-2col      { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2col-lg   { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.sidebar-layout { display: grid; grid-template-columns: 200px 1fr; gap: 22px; align-items: start; }
.sidebar-layout-lg { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: start; }
.tbl-scroll     { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─── Helpers ───────────────────────────────── */
.flex   { display: flex; }
.iflex  { display: inline-flex; }
.grid   { display: grid; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1  { gap: 4px; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-5  { gap: 20px; }
.gap-6  { gap: 24px; }
.mb-1   { margin-bottom: 4px; }
.mb-2   { margin-bottom: 8px; }
.mb-3   { margin-bottom: 12px; }
.mb-4   { margin-bottom: 16px; }
.mb-5   { margin-bottom: 20px; }
.mb-6   { margin-bottom: 24px; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-3   { margin-top: 12px; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.p-0    { padding: 0; }
.w-full { width: 100%; }
.text-xs   { font-size: .74rem; }
.text-sm   { font-size: .84rem; }
.text-base { font-size: .9rem; }
.text-lg   { font-size: 1.05rem; }
.text-xl   { font-size: 1.2rem; }
.font-medium{ font-weight: 500; }
.font-bold  { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.text-light { color: var(--text-light); }
.text-mid   { color: var(--text-mid); }
.text-indigo{ color: var(--indigo); }
.text-pink  { color: var(--pink); }
.text-emerald{color: var(--emerald); }
.text-amber { color: var(--amber); }
.truncate   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rounded    { border-radius: var(--r); }
.rounded-sm { border-radius: var(--r-sm); }
.rounded-lg { border-radius: var(--r-lg); }
.rounded-full{border-radius: var(--r-pill); }
.shadow-sm  { box-shadow: var(--shadow-sm); }
.shadow     { box-shadow: var(--shadow); }

/* ─── Responsive ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .topbar-menu-btn { display: flex; }
  .topbar-search { display: none; }
  .topbar-search-mobile { display: flex !important; }
  .page-body { padding: 16px; }
  .page-hd { flex-direction: column; gap: 12px; }
  .page-hd-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .page-hd-actions .btn { flex: 1; justify-content: center; min-width: 120px; }

  /* Grid utilities → single column */
  .stats-grid          { grid-template-columns: repeat(2,1fr) !important; }
  .grid-2col           { grid-template-columns: 1fr !important; }
  .grid-2col-lg        { grid-template-columns: 1fr !important; }
  .sidebar-layout      { grid-template-columns: 1fr !important; }
  .sidebar-layout-lg   { grid-template-columns: 1fr !important; }

  /* Modals — full width, scrollable */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0;
    max-height: 92dvh;
    overflow-y: auto;
    transform: translateY(100%) scale(1) !important;
  }
  .modal-overlay.open .modal { transform: translateY(0) scale(1) !important; }

  /* Notification dropdown — full width on mobile */
  #notif-dropdown { width: 96vw !important; right: -8px !important; }

  /* Hide decorative banner lottie on very small screens */
  :root { --lottie-banner-display: none; }

  /* Kanban — horizontal scroll, snap */
  .kanban { scroll-snap-type: x mandatory; }
  .kanban-col { scroll-snap-align: start; }

  .sb-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,.4); z-index: 99;
  }
  .sb-overlay.open { display: block; }

  /* On mobile the sidebar scrolls itself — bypass the inner flex wrapper */
  .sidebar {
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    height: 100dvh !important;
  }
  .sb-scroll {
    flex: none !important;
    height: auto !important;
    overflow: visible !important;
    min-height: 0 !important;
  }

  body.sb-open { overflow: hidden; }
}
