/* ===================================================================
   Universal Menu Analyser — Slice 0
   Verification Interface
   =================================================================== */

/* --- Reset --- */

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

/* --- Custom Properties --- */

:root {
  --bg: #2D3436;
  --bg-raised: #353b3d;
  --bg-inset: #242929;
  --accent: #C75B39;
  --highlight: #E8B86D;
  --text: #F7F3ED;
  --text-muted: rgba(247, 243, 237, 0.55);
  --text-dim: rgba(247, 243, 237, 0.35);

  --green: #4a9e6d;
  --green-bg: rgba(74, 158, 109, 0.12);
  --red: #c75b5b;
  --red-bg: rgba(199, 91, 91, 0.12);
  --amber: #d4a14a;
  --amber-bg: rgba(212, 161, 74, 0.12);
  --purple: #9b7ec8;
  --grey: rgba(247, 243, 237, 0.4);

  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --max-width: 720px;
}

/* --- Base --- */

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--highlight);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Layout --- */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg) var(--space-xl);
}

@media (max-width: 520px) {
  main {
    padding: var(--space-xl) var(--space-md) var(--space-lg);
  }
}

/* --- Header --- */

header {
  margin-bottom: var(--space-xl);
}

h1 {
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}

.subtitle {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: var(--space-xs);
}

.description {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-top: var(--space-md);
  line-height: 1.65;
  max-width: 600px;
}

/* --- Search Section --- */

.search-section {
  position: relative;
}

.input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: stretch;
}

#search-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-inset);
  color: var(--text);
  border: 1.5px solid rgba(247, 243, 237, 0.1);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease;
}

#search-input::placeholder {
  color: var(--text-dim);
}

#search-input:focus {
  border-color: var(--accent);
}

#classify-btn {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0 var(--space-lg);
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

#classify-btn:hover {
  background: #b5502f;
}

#classify-btn:active {
  background: #a34728;
}

#settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid rgba(247, 243, 237, 0.1);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

#settings-btn:hover {
  color: var(--text);
  border-color: rgba(247, 243, 237, 0.25);
}

/* --- Suggestions --- */

.suggestions {
  margin-top: var(--space-sm);
}

.suggestions:empty {
  display: none;
}

.suggestion-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s ease;
}

.suggestion-item:hover {
  background: var(--bg-raised);
}

.suggestion-name {
  font-size: 0.9375rem;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.category-badge {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.category-badge[data-cat="A"] { background: var(--red-bg); color: var(--red); }
.category-badge[data-cat="B"] { background: rgba(199, 139, 57, 0.15); color: #c78b39; }
.category-badge[data-cat="C"] { background: var(--amber-bg); color: var(--amber); }
.category-badge[data-cat="D"] { background: rgba(155, 126, 200, 0.15); color: var(--purple); }
.category-badge[data-cat="E"] { background: rgba(247, 243, 237, 0.08); color: var(--grey); }
.category-badge[data-cat="V"] { background: var(--green-bg); color: var(--green); }

/* --- Result Panel --- */

.result-panel {
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(247, 243, 237, 0.06);
}

.result-panel[hidden] {
  display: none;
}

.result-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
}

.badge.vegan {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(74, 158, 109, 0.25);
}

.badge.not-vegan {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(199, 91, 91, 0.25);
}

.badge.uncertain {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid rgba(212, 161, 74, 0.25);
}

.confidence {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.result-tier {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  line-height: 1.5;
}

.result-tier:empty {
  display: none;
}

.result-triggers {
  margin-bottom: var(--space-md);
}

.result-triggers:empty {
  display: none;
}

.trigger-item {
  font-size: 0.875rem;
  color: var(--text);
  padding: var(--space-xs) 0;
  line-height: 1.5;
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
}

.trigger-item::before {
  content: '\2192';
  color: var(--text-dim);
  flex-shrink: 0;
}

.trigger-ref {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.result-flags {
  margin-bottom: var(--space-md);
}

.result-flags:empty {
  display: none;
}

.flags-heading {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.flag-item {
  font-size: 0.8125rem;
  color: var(--amber);
  padding: 2px 0;
  line-height: 1.5;
}

/* --- Narration Section --- */

.narration-section {
  border-top: 1px solid rgba(247, 243, 237, 0.06);
  padding-top: var(--space-lg);
  margin-top: var(--space-md);
}

.narration-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-md);
}

.narration-content {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.narration-content.loading::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--text-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: var(--space-sm);
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.narration-note {
  font-size: 0.8125rem;
  color: var(--text-dim);
  font-style: italic;
}

/* --- V9 Block Notice --- */

.v9-notice {
  font-size: 0.8125rem;
  color: var(--green);
  opacity: 0.8;
  padding: 2px 0;
  line-height: 1.5;
}

.v9-notice::before {
  content: '\2713 ';
}

/* --- Vegan Override Notice --- */

.vegan-override-notice {
  font-size: 0.8125rem;
  color: var(--green);
  opacity: 0.8;
  padding: 2px 0;
  line-height: 1.5;
}

.vegan-override-notice::before {
  content: '\2713 ';
}

/* --- Settings Dialog --- */

dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 440px;
  width: calc(100% - var(--space-xl));
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid rgba(247, 243, 237, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  z-index: 100;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

dialog h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

dialog p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-lg);
}

dialog label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

dialog input[type="password"] {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-inset);
  color: var(--text);
  border: 1.5px solid rgba(247, 243, 237, 0.1);
  border-radius: var(--radius-md);
  outline: none;
  margin-bottom: var(--space-lg);
}

dialog input[type="password"]:focus {
  border-color: var(--accent);
}

.dialog-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.btn-primary {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: var(--space-sm) var(--space-lg);
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.btn-primary:hover {
  background: #b5502f;
}

.btn-secondary {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: var(--space-sm) var(--space-lg);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(247, 243, 237, 0.1);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: rgba(247, 243, 237, 0.2);
}

/* --- Footer --- */

footer {
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(247, 243, 237, 0.06);
}

footer p {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

footer a {
  color: var(--text-dim);
}

footer a:hover {
  color: var(--text-muted);
}

/* --- Responsive --- */

@media (max-width: 520px) {
  h1 {
    font-size: 1.375rem;
  }

  .input-row {
    flex-wrap: wrap;
  }

  #search-input {
    width: 100%;
    order: 1;
  }

  #classify-btn {
    flex: 1;
    order: 2;
    padding: var(--space-sm) var(--space-md);
  }

  #settings-btn {
    order: 3;
  }

  .suggestion-item {
    gap: var(--space-sm);
  }

  .suggestion-sub {
    display: none;
  }

  .result-panel {
    padding: var(--space-md);
  }
}

/* --- Feedback Section --- */

.feedback-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(247, 243, 237, 0.1);
}

.btn-mark-wrong {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}

.btn-mark-wrong:hover {
  background: var(--accent);
  color: var(--bg);
}

.feedback-form {
  margin-top: 12px;
}

.feedback-form label {
  display: block;
  font-size: 0.85rem;
  margin-top: 12px;
  margin-bottom: 4px;
  color: var(--text);
  opacity: 0.8;
}

.feedback-form select,
.feedback-form textarea,
.feedback-form input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  background: rgba(247, 243, 237, 0.06);
  border: 1px solid rgba(247, 243, 237, 0.2);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
}

.feedback-form select:focus,
.feedback-form textarea:focus,
.feedback-form input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.feedback-form textarea {
  resize: vertical;
  min-height: 60px;
}

.feedback-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.feedback-status {
  margin-top: 8px;
  font-size: 0.85rem;
}

.feedback-status.success {
  color: #4caf50;
}

.feedback-status.error {
  color: var(--accent);
}

/* --- Print --- */

@media print {
  body {
    background: white;
    color: #111;
  }

  .result-panel {
    background: #f5f5f5;
    border: 1px solid #ccc;
  }

  .search-section,
  #settings-btn,
  footer {
    display: none;
  }
}
