/*
  Castellano shared design system.
  Palette/type nod to Spain via warm terracotta + ochre + azulejo-tile teal
  rather than flag red/yellow -- meant to read as "Spanish" without being
  a tourist cliche. Import this file (see base pattern below) on any page
  to inherit the same look; page-specific CSS should only add layout for
  that page's own content, not redefine colors/typography.
*/

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

:root {
  /* -- Palette -- */
  --color-bg: #FBF6EE;
  --color-surface: #FFFFFF;
  --color-surface-alt: #FBF6EE;
  --color-border: #E7DCC9;
  --color-text: #2B2118;
  --color-text-muted: #7A6A58;

  --color-primary: #B8451F;      /* terracotta */
  --color-primary-dark: #8F3417;
  --color-primary-light: #F3E0D3;

  --color-accent: #C79A3C;       /* ochre / gold */
  --color-accent-dark: #A17C28;
  --color-accent-light: #F3E7C9;

  --color-azulejo: #12586A;      /* Spanish tile teal-blue */
  --color-azulejo-dark: #0B3E4B;
  --color-azulejo-light: #D9EAEE;

  --color-success: #52733B;
  --color-success-light: #E4EEDD;
  --color-danger: #A6321B;
  --color-danger-light: #F6DED8;
  --color-info: var(--color-azulejo);
  --color-info-light: var(--color-azulejo-light);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(43, 33, 24, 0.08);
  --shadow-md: 0 6px 24px rgba(43, 33, 24, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--color-primary-dark);
  margin: 0 0 8px;
}

a { color: var(--color-azulejo); }
a:hover { color: var(--color-azulejo-dark); }

/* Decorative azulejo-tile accent strip -- a subtle nod to Spanish tilework,
   used under page headers instead of an image asset. */
.tile-accent {
  height: 5px;
  width: 100%;
  max-width: 220px;
  margin: 0 auto 28px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    90deg,
    var(--color-primary) 0 16px,
    var(--color-accent) 16px 32px,
    var(--color-azulejo) 32px 48px
  );
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  position: relative;
}

.page-header {
  text-align: center;
  margin-bottom: 8px;
}

.page-header h1 {
  font-size: 2.1em;
}

/* -- Top-right nav (Home / Logout) -- */
.top-nav {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
}

/* -- Buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }

.btn-azulejo { background: var(--color-azulejo); color: #fff; }
.btn-azulejo:hover { background: var(--color-azulejo-dark); color: #fff; }

.btn-outline {
  background: var(--color-surface);
  color: var(--color-primary-dark);
  border-color: var(--color-border);
}
.btn-outline:hover { background: var(--color-primary-light); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #7d2513; color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 0.85em; }

/* -- Cards / panels -- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* -- Flash messages -- */
.flashes { list-style: none; padding: 0; margin: 0 0 20px; text-align: center; }
.flashes li {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 0.92em;
}
.flashes li.danger { background: var(--color-danger-light); color: var(--color-danger); }
.flashes li.success { background: var(--color-success-light); color: var(--color-success); }
.flashes li.info { background: var(--color-info-light); color: var(--color-azulejo-dark); }

/* -- Badges (source tags, vocab tags) -- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8em;
  font-weight: 600;
}
.badge-source { background: var(--color-azulejo-light); color: var(--color-azulejo-dark); }
.badge-tag { background: var(--color-accent-light); color: var(--color-accent-dark); margin: 2px 4px 2px 0; }

/* -- Tables -- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  min-width: 900px;
}
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.92em;
}
.data-table thead th {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  position: sticky;
  top: 0;
  white-space: nowrap;
  user-select: none;
}
.data-table thead th:hover { background: var(--color-accent-light); }
.data-table thead th .sort-arrow { margin-left: 4px; color: var(--color-primary); }
.data-table tbody tr:hover { background: var(--color-surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }
.extra-info-list { margin: 0; padding-left: 18px; }

/* -- Forms / filter panel -- */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.controls input[type="text"] {
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 240px;
  font-family: var(--font-body);
  background: var(--color-surface);
}
.controls input[type="text"]:focus {
  outline: none;
  border-color: var(--color-azulejo);
}

.filter-panel {
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--color-surface);
}
.filter-panel summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-primary-dark);
  font-size: 1.05em;
}
.filter-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 18px;
  margin-top: 16px;
}
.filter-group h4 {
  margin: 0 0 8px;
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.filter-group label {
  display: block;
  font-size: 0.9em;
  font-weight: 400;
  padding: 3px 0;
  cursor: pointer;
}
.filter-group input[type="checkbox"] { margin-right: 6px; accent-color: var(--color-primary); }

/* Tags tends to be a much longer list than the other filter groups --
   contain it in its own scrollable box instead of stretching the whole
   panel's height, and give it more columns since it has more room. */
.filter-group-tags {
  grid-column: span 2;
}
.tag-scroll {
  max-height: 190px;
  overflow-y: auto;
  columns: 2;
  column-gap: 16px;
  padding-right: 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  padding: 8px 10px;
}
.tag-scroll label {
  break-inside: avoid;
}
.tag-scroll::-webkit-scrollbar { width: 8px; }
.tag-scroll::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }
.tag-scroll::-webkit-scrollbar-track { background: transparent; }
.filter-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}

.navigation-links {
  margin-top: 24px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* -- Centered card shell (auth, forms, quiz) -- used by narrower
   single-column pages, as opposed to .page-shell's wide table layout. */
.center-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.center-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 36px;
  width: 100%;
  max-width: 480px;
  box-sizing: border-box;
}
.center-card.wide { max-width: 640px; }
.center-card h1 {
  text-align: center;
  font-size: 1.7em;
  margin-bottom: 4px;
}
.center-card .tile-accent { margin: 0 auto 22px; }
.center-card p.hint-text {
  text-align: center;
  color: var(--color-text-muted);
  margin-top: 18px;
  font-size: 0.92em;
}

/* -- Generic form controls, shared by every form page -- */
form.stack { display: flex; flex-direction: column; gap: 16px; }
.form-group { margin-bottom: 4px; }
.form-group label,
form.stack > label {
  display: block;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
  font-size: 0.92em;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1em;
  font-family: var(--font-body);
  width: 100%;
  box-sizing: border-box;
  background: var(--color-surface);
  color: var(--color-text);
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-azulejo);
}
textarea { resize: vertical; min-height: 110px; }

.checkbox-group, .radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 4px;
}
.checkbox-group label, .radio-group label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 0.92em;
}
.checkbox-group input, .radio-group input { accent-color: var(--color-primary); }

fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px 16px;
  margin: 0 0 16px;
}
legend {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-primary-dark);
  padding: 0 6px;
}

/* -- Quiz cards -- */
.quiz-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 40px;
  text-align: center;
  width: 100%;
  max-width: 620px;
  box-sizing: border-box;
}
.word-display {
  font-family: var(--font-display);
  font-size: 2.3em;
  font-weight: 700;
  color: var(--color-primary);
  margin: 4px 0 20px;
  word-wrap: break-word;
}
.quiz-container .extra-info-list {
  list-style: none;
  padding: 0;
  margin: 18px 0;
  text-align: left;
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
}
.quiz-container .extra-info-list li { margin-bottom: 6px; font-size: 0.95em; color: var(--color-text-muted); }
.quiz-container .extra-info-list li strong { color: var(--color-text); }
.hint-section { margin-top: 14px; border-top: 1px solid var(--color-border); padding-top: 14px; }
.notes-content {
  display: none;
  margin-top: 10px;
  padding: 12px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: left;
  font-style: italic;
  color: var(--color-text-muted);
  font-size: 0.92em;
}
.answer-form { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.message-box {
  margin-top: 18px;
  padding: 13px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  display: none;
  font-size: 0.92em;
}
/* Deliberately vivid, high-saturation feedback colors here -- unlike the
   rest of the app's muted palette, a quiz answer's correct/incorrect
   signal needs to read unambiguously at a glance, not blend in. */
.message-box.correct { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.message-box.incorrect { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.hint-button {
  background: #28a745;
  color: #fff;
  border: none;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95em;
  font-weight: 600;
}
.hint-button:hover { background: #218838; }
.quiz-action-buttons { margin-top: 18px; display: flex; gap: 10px; justify-content: center; }

/* -- Word insight (external dictionary / example lookups) -- */
.word-insight { margin-top: 16px; }
.word-insight-content {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-azulejo);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.92em;
  color: var(--color-text);
}
.word-insight-content h4 {
  font-family: var(--font-body);
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin: 14px 0 6px;
}
.word-insight-content h4:first-child { margin-top: 0; }
.word-insight-defs, .word-insight-examples { margin: 0; padding-left: 18px; }
.word-insight-defs li, .word-insight-examples li { margin-bottom: 8px; }
.wi-pos { font-style: italic; color: var(--color-text-muted); }
.wi-example { font-style: italic; color: var(--color-text-muted); margin-top: 3px; }
.word-insight-examples .wi-es { display: block; }
.word-insight-examples .wi-en { display: block; color: var(--color-text-muted); }
.word-insight-lemma { margin: 0 0 10px; font-size: 0.9em; color: var(--color-text-muted); }
.word-insight-lemma strong { color: var(--color-text); }
.word-insight-src { margin: 12px 0 0; font-size: 0.85em; color: var(--color-text-muted); }
.word-insight-empty { margin: 0; color: var(--color-text-muted); font-style: italic; }
.word-insight-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* -- Word flagging (user report + admin review) -- */
.flag-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 33, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.flag-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px 26px;
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  text-align: left;
}
.flag-modal h3 { margin: 0 0 4px; font-family: var(--font-display); color: var(--color-primary-dark); }
.flag-modal-sub { margin: 0 0 16px; color: var(--color-text-muted); font-size: 0.9em; }
.flag-reason-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.flag-reason-list label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.92em;
  font-weight: 400;
  cursor: pointer;
}
.flag-reason-list input { accent-color: var(--color-primary); margin-top: 3px; }
.flag-comment-label { display: block; font-weight: 600; font-size: 0.88em; margin-bottom: 6px; }
.flag-form-msg { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.9em; }
.flag-form-msg.ok { background: var(--color-success-light); color: var(--color-success); }
.flag-form-msg.error { background: var(--color-danger-light); color: var(--color-danger); }
.flag-modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.flag-pill {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-lg);
  padding: 3px 10px;
  font-size: 0.85em;
  font-weight: 700;
  cursor: pointer;
}
.flag-pill:hover { background: var(--color-danger); color: #fff; }
.flag-none { color: var(--color-text-muted); font-size: 0.9em; }

.flag-filter-tabs { display: flex; gap: 8px; margin: 12px 0 20px; flex-wrap: wrap; }
.flag-word-card { margin-bottom: 18px; padding: 16px 18px; }
.flag-word-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.flag-word-es { font-family: var(--font-display); font-size: 1.2em; font-weight: 700; color: var(--color-primary); }
.flag-word-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.flag-entry {
  border-top: 1px solid var(--color-border);
  padding: 12px 0 4px;
}
.flag-entry.flag-resolved { opacity: 0.6; }
.flag-entry-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 0.9em; }
.flag-date { color: var(--color-text-muted); font-size: 0.85em; }
.flag-status-tag {
  text-transform: uppercase;
  font-size: 0.7em;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-light);
  color: var(--color-accent-dark);
}
.flag-reasons { margin: 8px 0; padding-left: 18px; font-size: 0.9em; }
.flag-reasons li { margin-bottom: 3px; }
.flag-comment {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  border-left: 3px solid var(--color-azulejo);
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  white-space: pre-wrap;
}
.word-flags-body { max-height: 55vh; overflow-y: auto; margin-bottom: 8px; }

/* -- Status messages (import result, etc.) -- */
.status-message {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.95em;
}
.status-message.success { background: var(--color-success-light); color: var(--color-success); }
.status-message.error, .status-message.danger { background: var(--color-danger-light); color: var(--color-danger); }

/* -- Forum -- */
.forum-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.forum-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  transition: box-shadow 0.15s ease;
}
.forum-item:hover { box-shadow: var(--shadow-sm); }
.forum-item a { font-family: var(--font-display); font-size: 1.15em; font-weight: 700; text-decoration: none; }
.forum-item p { margin: 6px 0 0; color: var(--color-text-muted); }
.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.post-card .post-meta { color: var(--color-text-muted); font-size: 0.85em; margin-bottom: 10px; }
.post-card .post-meta strong { color: var(--color-text); }

/* -- Landing page menu grid -- a wide grid of destination tiles instead of
   a stack of pill buttons crammed into a narrow card. Each tile gets a
   category accent stripe (top border) instead of a fully-colored button,
   so the grouping reads as deliberate rather than arbitrary. */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 8px;
}
.menu-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.menu-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.menu-tile .tile-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15em;
  color: var(--color-text);
}
.menu-tile .tile-desc { font-size: 0.85em; color: var(--color-text-muted); }
.menu-tile.accent-primary { border-top-color: var(--color-primary); }
.menu-tile.accent-azulejo { border-top-color: var(--color-azulejo); }
.menu-tile.accent-gold { border-top-color: var(--color-accent); }
.tile-section-label {
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 28px 0 10px;
}
.tile-section-label:first-of-type { margin-top: 4px; }

.stat-strip {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 24px;
}
.stat-strip-item {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.92em;
  box-shadow: var(--shadow-sm);
}
a.stat-strip-link {
  text-decoration: none;
  cursor: pointer;
}
a.stat-strip-link:hover { box-shadow: var(--shadow-md); }
