/* ASEAN Food Regulation Tracker — POC Stylesheet */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Navbar ─────────────────────────── */
.navbar {
  background: var(--primary);
  color: white;
  padding: 12px 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  color: white;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 700;
}
.nav-links a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  margin-left: 20px;
  font-size: 0.9rem;
}
.nav-links a:hover {
  color: white;
}

/* ── Footer ─────────────────────────── */
.footer {
  background: var(--text);
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
  font-size: 0.85rem;
  margin-top: 40px;
}

/* ── Buttons ────────────────────────── */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: white;
  transition: background 0.2s;
}
.btn:hover {
  background: var(--primary-dark);
}
.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: white;
}
.btn-active {
  background: var(--primary-dark);
  color: white;
  pointer-events: none;
}

/* ── Dashboard ──────────────────────── */
.dashboard {
  padding: 24px 0;
}
.dashboard h1 {
  margin-bottom: 8px;
}
.subtitle {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.stat-card:hover {
  transform: translateY(-2px);
}
.stat-flag {
  font-size: 2.5rem;
}
.stat-info h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}
.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.stat-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 4px 0 8px;
}

.quick-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ── Empty State ────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state code {
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ── Filter Form ────────────────────── */
.filter-form {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-row select,
.filter-row input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: white;
  min-width: 140px;
}
.filter-row input[type="text"] {
  flex: 1;
  min-width: 200px;
}

.results-info {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

/* ── Table ──────────────────────────── */
.table-wrap {
  overflow-x: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  background: #f1f5f9;
  padding: 12px;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
td a {
  color: var(--primary);
  text-decoration: none;
}
td a:hover {
  text-decoration: underline;
}
tr:hover {
  background: #f8fafc;
}
.center {
  text-align: center;
}
.mono {
  font-family: monospace;
  font-size: 0.85rem;
}

/* ── Badge ──────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  background: #e0e7ff;
  color: var(--primary-dark);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}
.badge-lg {
  padding: 4px 12px;
  font-size: 0.9rem;
}

/* ── Pagination ─────────────────────── */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 24px 0;
  flex-wrap: wrap;
}

/* ── Detail Page ────────────────────── */
.breadcrumb {
  padding: 16px 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.detail-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.detail-flag {
  font-size: 0.95rem;
  color: var(--text-muted);
}
.detail-card h1 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  line-height: 1.4;
}
.title-en {
  color: var(--text-muted);
  margin-bottom: 16px;
}
.detail-meta {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}
.meta-row {
  display: flex;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
}
.meta-label {
  font-weight: 600;
  width: 120px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.meta-value {
  flex: 1;
}

.detail-links {
  margin-top: 16px;
}
.detail-timestamps {
  margin-top: 16px;
  color: var(--text-muted);
}

/* ── Error Page ─────────────────────── */
.error-page {
  text-align: center;
  padding: 48px;
}
.error-page h1 {
  margin-bottom: 16px;
}
.error-page p {
  margin-bottom: 24px;
  color: var(--text-muted);
}

/* ── Responsive ─────────────────────── */
@media (max-width: 768px) {
  .navbar .container {
    flex-direction: column;
    gap: 8px;
  }
  .filter-row {
    flex-direction: column;
  }
  .filter-row select,
  .filter-row input[type="text"] {
    width: 100%;
    min-width: unset;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Detail sections (MongoDB content) */
.detail-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}
.detail-section h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  color: #374151;
}
.detail-content {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  max-height: 600px;
  overflow-y: auto;
}
.detail-content.pdf-text pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
}
.detail-content.html-content img {
  max-width: 100%;
}
.detail-content.html-content table {
  border-collapse: collapse;
  width: 100%;
}
.detail-content.html-content td,
.detail-content.html-content th {
  border: 1px solid #d1d5db;
  padding: 6px 10px;
  text-align: left;
}
