/* ── Shared App Theme ───────────────────────────────────────────
   Imported by all inner pages. Overrides :root variables to match
   the landing page warm palette and injects the sticky app-nav.
   ─────────────────────────────────────────────────────────────── */

/* Font (same as landing page) */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ── CSS Variable Overrides ─────────────────────────────────────
   These beat the :root blocks in page-specific <style> tags because
   shared.css is loaded AFTER the inline <style> via <link>.       */
:root {
  --bg:            #fdf8f3;
  --surface:       #ffffff;
  --surface-warm:  #f5f0e8;
  --border:        #d0d0d0;
  --text:          #1a1a1a;
  --text-muted:    #4a4a4a;
  --primary:       #1a1a1a;
  --primary-dark:  #000000;
  --primary-light: #f5f0e8;
  --accent:        #32cd32;
  --counselor-bg:  #f5f0e8;
  --student-bg:    #1a1a1a;
  --student-text:  #fdf8f3;
  --font: 'JetBrains Mono', monospace;
}

/* ── Dark Mode ──────────────────────────────────────────────────── */
html.theme-dark {
  --bg:            #1a1a1a;
  --surface:       #2a2a2a;
  --surface-warm:  #333333;
  --border:        #4a4a4a;
  --text:          #fdf8f3;
  --text-muted:    #d0d0d0;
  --primary:       #fdf8f3;
  --primary-dark:  #ffffff;
  --primary-light: #333333;
  --counselor-bg:  #2a2a2a;
  --student-bg:    #fdf8f3;
  --student-text:  #1a1a1a;
}

/* ── Base font ──────────────────────────────────────────────────── */
body { font-family: var(--font) !important; }

/* ── Dark mode button fixes ─────────────────────────────────────
   In dark mode --primary is cream (#fdf8f3), so btn-primary gets a
   cream background — but its text is hardcoded #fff, making it
   invisible. Switch to green accent with dark text instead.       */
html.theme-dark .btn-primary {
  background: var(--accent) !important;
  color: #1a1a1a !important;
}
html.theme-dark .btn-primary:hover:not(:disabled) {
  background: #28b428 !important;
  color: #1a1a1a !important;
}
/* btn-secondary hover: default goes to --primary bg + white text, both light in dark mode */
html.theme-dark .btn-secondary:hover {
  background: var(--accent) !important;
  color: #1a1a1a !important;
  border-color: var(--accent) !important;
}
/* cta-reviewer hover uses --primary bg + white text */
html.theme-dark .btn-cta-reviewer:hover {
  background: var(--accent) !important;
  color: #1a1a1a !important;
  border-color: var(--accent) !important;
}

/* ── Assessment-page hero recolour ──────────────────────────────
   Beats the hardcoded #1e40af/#3b82f6 gradient in inline <style>.  */
.hero {
  background: linear-gradient(135deg, var(--surface-warm) 0%, var(--bg) 100%) !important;
  color: var(--text) !important;
}
.hero h1, .hero p { color: var(--text) !important; }
.hero-back {
  color: var(--text-muted) !important;
  text-decoration: none;
}
.hero-back:hover { color: var(--text) !important; }

/* ── App Nav ────────────────────────────────────────────────────── */
.app-nav {
  background: var(--surface-warm);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.app-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
  gap: 1rem;
}

.app-nav-logo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
  font-family: var(--font);
  flex-shrink: 0;
}

.app-nav-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.app-nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font);
}

.app-nav-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  object-fit: cover;
}

.app-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  min-width: 28px;
  white-space: nowrap;
}
.app-nav-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ── User dropdown menu ─────────────────────────────────────────── */
.app-nav-user-menu {
  position: relative;
}

.app-nav-user-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px 0 6px;
  height: 28px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.app-nav-user-trigger:hover {
  border-color: var(--text);
  color: var(--text);
}

.app-nav-caret {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.app-nav-user-trigger[aria-expanded="true"] .app-nav-caret {
  transform: rotate(180deg);
}

.app-nav-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 150px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1001;
}
.app-nav-dropdown[hidden] { display: none; }

.app-nav-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.app-nav-dropdown-item:hover {
  background: var(--surface);
  color: var(--text);
}

@media (max-width: 500px) {
  .app-nav-user span { display: none; }
  .app-nav-btn[data-label] { font-size: 0; }
}

.app-nav-dropdown-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* ── Share-my-essays modal (injected by shared.js) ──────────────────
   Self-contained, te- prefixed so it never collides with page styles.  */
.te-modal-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 1rem 1rem;
}
.te-modal-overlay[hidden] { display: none; }
.te-modal {
  width: 100%; max-width: 520px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden; font-family: var(--font);
}
.te-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; padding: 1.1rem 1.25rem 0.9rem; border-bottom: 1px solid var(--border);
}
.te-modal-title { font-size: 1rem; font-weight: 800; color: var(--text); }
.te-modal-title small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.te-modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.te-modal-close:hover { color: var(--text); }
.te-modal-body { padding: 1.1rem 1.25rem 1.25rem; }

.te-share-row { display: flex; gap: 0.5rem; }
.te-field { flex: 1; min-width: 0; }
.te-field-rel { flex: 0 0 170px; max-width: 170px; }
.te-field-label { display: block; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; }
.te-input, .te-select {
  font-family: var(--font); font-size: 0.8rem; width: 100%; height: 38px;
  padding: 0 0.7rem; border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); color: var(--text); outline: none;
}
.te-input:focus, .te-select:focus { border-color: var(--accent); }
.te-input::placeholder { color: var(--text-muted); }
.te-field-hint { font-size: 0.66rem; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.te-field-hint.err { color: #d33; }
html.theme-dark .te-field-hint.err { color: #e08a8a; }

.te-share-actions { display: flex; justify-content: flex-end; margin-top: 0.9rem; }
.te-btn { font-family: var(--font); font-size: 0.78rem; font-weight: 600; border-radius: 6px; padding: 0 1rem; height: 36px; cursor: pointer; border: 1px solid transparent; }
.te-btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.te-btn-primary:hover:not(:disabled) { background: #000; }
.te-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
html.theme-dark .te-btn-primary { background: var(--accent); color: #10240f; border-color: var(--accent); }
html.theme-dark .te-btn-primary:hover:not(:disabled) { background: #28b428; }

.te-share-list-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 1.4rem 0 0.6rem; }
.te-reviewer-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); margin-bottom: 0.5rem; }
.te-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 800; background: var(--accent); color: #10240f; }
.te-reviewer-meta { flex: 1; min-width: 0; }
.te-reviewer-email { font-size: 0.78rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.te-reviewer-rel { font-size: 0.66rem; color: var(--text-muted); }
.te-icon-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.95rem; padding: 4px; border-radius: 5px; flex-shrink: 0; }
.te-icon-btn:hover { color: #d33; background: rgba(221, 51, 51, 0.08); }
html.theme-dark .te-icon-btn:hover { color: #ffb4b4; background: rgba(224, 138, 138, 0.12); }
