/* ─────────────────────────────────────────────────────────────────────────────
   AFO Knowledge Repository — Global Stylesheet
   Action For Ocean · Tanzania · v1.0 · 2026
───────────────────────────────────────────────────────────────────────────── */

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

/* ── CSS Variables ────────────────────────────────────────────────────────── */
:root {
  --deep-blue:   #0d2b4e;
  --ocean-blue:  #1565C0;
  --teal:        #00897B;
  --teal-dark:   #00695C;
  --coral:       #E64A19;
  --sand:        #f5f0e8;
  --sand-dark:   #ede6d8;
  --white:       #ffffff;
  --border:      #dde3ef;
  --ink:         #1a2232;
  --ink-mid:     #4a5568;
  --ink-light:   #718096;
  --success:     #2e7d32;
  --danger:      #c62828;
  --warning:     #e65100;
  --info:        #1565c0;

  --radius:      6px;
  --radius-lg:   12px;
  --shadow:      0 2px 12px rgba(13,43,78,0.10);
  --shadow-lg:   0 8px 32px rgba(13,43,78,0.16);
  --transition:  0.2s ease;

  --font-body:   'Inter', system-ui, sans-serif;
  --font-serif:  'Playfair Display', Georgia, serif;
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

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

a { color: var(--ocean-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

h1, h2, h3, h4, h5 { line-height: 1.25; font-weight: 700; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-family: var(--font-serif); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-mid);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Container ────────────────────────────────────────────────────────────── */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mono   { font-family: 'Courier New', monospace; font-size: 0.88em; }
.req    { color: var(--coral); }

/* ── Navigation ───────────────────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--deep-blue);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
}
.nav-brand img { height: 28px; width: auto; }
.nav-brand span { font-family: var(--font-serif); font-size: 1.05rem; }

.nav-links {
  display: flex;
  align-items: center;
  list-style: none;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.nav-links a {
  color: rgba(255,255,255,0.8);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}
.nav-links a:hover, .nav-links a.active {
  color: white;
  background: rgba(255,255,255,0.12);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  border-left: 1px solid rgba(255,255,255,0.15);
  padding-left: 0.75rem;
  margin-left: 0.25rem;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--deep-blue) 0%, var(--ocean-blue) 100%);
  color: white;
  padding: 5rem 0 4rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-content { position: relative; }
.hero-label {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 0.3rem 0.9rem;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.hero h1 { margin-bottom: 1rem; max-width: 680px; }
.hero p   { font-size: 1.05rem; color: rgba(255,255,255,0.8); max-width: 560px; margin-bottom: 2rem; }

.search-bar {
  display: flex;
  gap: 0;
  max-width: 560px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.search-input {
  flex: 1;
  padding: 0.85rem 1.25rem;
  border: none;
  font-size: 1rem;
  outline: none;
  font-family: var(--font-body);
}
.search-btn {
  background: var(--teal);
  color: white;
  border: none;
  padding: 0.85rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  font-family: var(--font-body);
}
.search-btn:hover { background: var(--teal-dark); }

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.5rem;
}
.stat-card { text-align: center; padding: 0.5rem; }
.stat-number { font-size: 2.2rem; font-weight: 800; color: var(--ocean-blue); line-height: 1; }
.stat-label  { font-size: 0.8rem; color: var(--ink-light); margin-top: 0.3rem; }

/* ── Section ──────────────────────────────────────────────────────────────── */
.section { padding: 3rem 0; }
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.section-title    { font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.section-subtitle { font-size: 0.88rem; color: var(--ink-light); margin-top: 0.25rem; }

/* ── Page header (interior pages) ────────────────────────────────────────── */
.page-header {
  background: var(--deep-blue);
  color: white;
  padding: 2rem 0;
}
.page-header h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
.page-header p  { color: rgba(255,255,255,0.7); font-size: 0.9rem; margin-top: 0.35rem; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow); }

.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* Document card */
.doc-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  color: var(--ink);
}
.doc-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.doc-card-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.75rem; }
.doc-title { font-weight: 700; font-size: 0.95rem; line-height: 1.4; color: var(--deep-blue); }
.doc-meta  { font-size: 0.8rem; color: var(--ink-light); margin-top: 0.25rem; }
.doc-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 0.75rem; border-top: 1px solid var(--border); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-public     { background: #e8f5e9; color: #1b5e20; }
.badge-partner    { background: #e3f2fd; color: #0d47a1; }
.badge-internal   { background: #fff8e1; color: #e65100; }
.badge-restricted { background: #fce4ec; color: #880e4f; }
.badge-seascape   { background: var(--deep-blue); color: white; }
.badge-type       { background: #f0f4f8; color: var(--ink-mid); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  font-family: var(--font-body);
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--ocean-blue); color: white; }
.btn-primary:hover { background: #0d47a1; }

.btn-teal { background: var(--teal); color: white; }
.btn-teal:hover { background: var(--teal-dark); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b71c1c; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-mid);
}
.btn-outline:hover { border-color: var(--ocean-blue); color: var(--ocean-blue); background: #f0f5ff; }

.btn-ghost { background: transparent; color: var(--ink-mid); }
.btn-ghost:hover { background: #f0f4f8; }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.75rem; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 0; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--ink);
  background: white;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--ocean-blue);
  box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
}
.form-control::placeholder { color: var(--ink-light); }

textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 0.78rem; color: var(--ink-light); margin-top: 0.25rem; }
.form-section {
  background: var(--sand);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.form-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mid);
  margin-bottom: 1.1rem;
}

/* Tag input style */
.tag-input-area {
  min-height: 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  cursor: text;
  background: white;
}
.tag-input-area:focus-within { border-color: var(--ocean-blue); box-shadow: 0 0 0 3px rgba(21,101,192,0.12); }
.tag-input-area input {
  border: none;
  outline: none;
  font-size: 0.9rem;
  min-width: 120px;
  flex: 1;
  font-family: var(--font-body);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #e3f2fd;
  color: #1565c0;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
}
.tag-remove { cursor: pointer; opacity: 0.6; line-height: 1; }
.tag-remove:hover { opacity: 1; }

/* Chips (indicator selector) */
.chip-group { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  padding: 0.25rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--ink-mid);
}
.chip:hover, .chip.selected {
  border-color: var(--teal);
  background: #e0f2f1;
  color: var(--teal-dark);
  font-weight: 600;
}

.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ── Search page specific ─────────────────────────────────────────────────── */
.search-filters {
  background: var(--sand);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1.5rem 0 1rem;
  font-size: 0.9rem;
  color: var(--ink-mid);
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}
.tab-btn {
  padding: 0.65rem 1.1rem;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--ocean-blue); }
.tab-btn.active { color: var(--ocean-blue); border-bottom-color: var(--ocean-blue); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13,43,78,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-body   { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--ink-light);
  padding: 0.25rem;
}

/* ── Loading & Spinner ────────────────────────────────────────────────────── */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--ink-light);
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--ocean-blue);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--ink-light);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3   { color: var(--ink-mid); margin-bottom: 0.5rem; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--deep-blue);
  color: rgba(255,255,255,0.65);
  padding: 2rem 0;
  margin-top: auto;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-brand { font-weight: 600; color: white; font-size: 0.95rem; }
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a { color: rgba(255,255,255,0.6); font-size: 0.85rem; }
.footer-links a:hover { color: white; text-decoration: none; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-lg);
  color: white;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: none; opacity:1; } }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--ocean-blue), var(--teal));
  transition: width 0.4s ease;
}

/* ── MEAL heatmap ─────────────────────────────────────────────────────────── */
.heatmap-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.heatmap-table th, .heatmap-table td { padding: 0.5rem 0.75rem; text-align: center; }
.heatmap-table th { background: var(--deep-blue); color: white; font-weight: 600; }
.heatmap-table tr:nth-child(even) { background: #f8fafc; }
.heatmap-table td:first-child { text-align: left; font-weight: 600; }
.heat-0 { color: var(--border); }
.heat-1 { color: #b3e5fc; font-weight: 600; }
.heat-2 { color: #29b6f6; font-weight: 700; }
.heat-3 { color: var(--ocean-blue); font-weight: 700; }
.heat-4 { color: var(--teal); font-weight: 800; }

/* ── Highlight (search results) ───────────────────────────────────────────── */
mark { background: #ffeb3b80; padding: 0 2px; border-radius: 2px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .section-header  { flex-direction: column; align-items: flex-start; }
  .footer-inner    { flex-direction: column; align-items: flex-start; }
  .nav-links       { gap: 0; }
  .nav-links a     { padding: 0.3rem 0.5rem; font-size: 0.82rem; }
  .search-filters  { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .search-filters  { grid-template-columns: 1fr; }
  .modal           { max-height: 95vh; }
}
