/* ─────────────────────────────────────────────────────────────────────────────
   TUITUS Editorial CMS — Light Theme Only
   Primary: Deep Navy (#16213E, #0F3460)
   Accent: Academic Gold (#E5A93C, #C9922A)
   Neutrals: Warm White (#F8FAFC, #F5F4EF), Cool Gray Scale (#E2E8F0, #475569)
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --navy-deep: #16213e;
  --navy-mid: #0f3460;
  --navy-light: #1f2937;
  --gold: #e5a93c;
  --gold-dark: #c9922a;
  --gold-light: #fef3c7;
  --gold-tint: rgba(229, 169, 60, 0.12);
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sub: #475569;
  --success: #059669;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.1);
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Typography & Headings ── */
h1, h2, h3, h4 {
  color: var(--navy-deep);
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ── Navigation / App Header ── */
.app-header {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: var(--navy-deep);
  color: var(--gold);
  font-weight: 900;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--navy-deep);
}

.brand-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.nav-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.nav-tab-btn:hover {
  color: var(--navy-deep);
}

.nav-tab-btn.active {
  background: var(--navy-deep);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--gold-tint);
  border: 1px solid rgba(229, 169, 60, 0.35);
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold-dark);
}

.btn-secondary {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-sub);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  color: var(--navy-deep);
}

/* ── Primary Gold Button ── */
.btn-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--gold);
  color: #000000 !important;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(229, 169, 60, 0.3);
  transition: all 0.18s ease;
  font-family: inherit;
}

.btn-gold:hover {
  background: #deb332;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(229, 169, 60, 0.4);
}

.btn-gold:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ── Main Layout: Two Column (Editor + Mobile Live Preview) ── */
.main-wrapper {
  display: grid;
  grid-template-columns: minmax(580px, 1fr) 420px;
  gap: 24px;
  padding: 24px 28px 40px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 1180px) {
  .main-wrapper {
    grid-template-columns: 1fr;
  }
  .mobile-preview-column {
    display: none;
  }
}

/* ── Editor Card ── */
.editor-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.editor-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy-deep);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--navy-deep);
  box-shadow: 0 0 0 3px rgba(22, 33, 62, 0.08);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

/* ── Rich Formatting Toolbar ── */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.tool-btn {
  background: #ffffff;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.tool-btn:hover {
  background: var(--gold-tint);
  border-color: var(--gold);
  color: var(--navy-deep);
}

/* ── Content Textarea ── */
.content-editor {
  min-height: 380px;
  font-family: "JetBrains Mono", monospace, var(--font);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ── Bento Blocks / Flashcard / LaTeX Helper Pills ── */
.insert-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill-insert-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  color: var(--navy-deep);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.pill-insert-btn:hover {
  background: var(--navy-deep);
  color: #ffffff;
  border-color: var(--navy-deep);
}

/* ── MCQ Check Box ── */
.mcq-builder-card {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mcq-item-row {
  display: grid;
  grid-template-columns: 28px 1fr 60px;
  align-items: center;
  gap: 8px;
}

/* ── Live Mobile Preview Frame ── */
.mobile-preview-column {
  position: sticky;
  top: 84px;
  height: calc(100vh - 100px);
}

.device-frame {
  width: 375px;
  height: 750px;
  background: #ffffff;
  border-radius: 40px;
  border: 10px solid #1e293b;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.25);
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.device-notch {
  width: 140px;
  height: 22px;
  background: #1e293b;
  border-radius: 0 0 14px 14px;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
}

.device-app-bar {
  background: var(--navy-deep);
  color: #ffffff;
  padding: 30px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.device-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-page);
  padding: 16px;
}

/* ── Mobile Preview Styled Components ── */
.prev-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--gold-tint);
  color: var(--gold-dark);
  margin-bottom: 8px;
}

.prev-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy-deep);
  line-height: 1.3;
  margin-bottom: 12px;
}

.prev-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.prev-bento {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 12px 0;
  font-size: 12.5px;
  color: var(--text-sub);
}

.prev-flashcard {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 12px 0;
  box-shadow: var(--shadow-sm);
}

.prev-flashcard-q {
  font-weight: 700;
  color: var(--navy-deep);
  font-size: 12px;
  margin-bottom: 6px;
}

.prev-flashcard-a {
  background: var(--bg-subtle);
  padding: 8px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--text-sub);
}

/* ── Status Banner / Modal / Feedback ── */
.toast-bar {
  position: fixed;
  bottom: 24px;
  right: 28px;
  padding: 14px 20px;
  background: var(--navy-deep);
  color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-bar.visible {
  transform: translateY(0);
  opacity: 1;
}

.toast-bar.success {
  border-left: 4px solid var(--success);
}

.toast-bar.error {
  border-left: 4px solid var(--danger);
}

/* ── Auth Overlay View (Same Supabase Login) ── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-modal {
  background: #ffffff;
  width: 420px;
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
