/* ---------------------------------------------------------------
   Middagsboken — stylesheet
   A quiet, logbook-style design: cool-neutral paper background,
   a single deep wine accent, hairline borders instead of shadows,
   and a geometric display face used sparingly for structure.
   ------------------------------------------------------------- */

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

:root {
  --color-bg: #F1F0EB;
  --color-surface: #FFFFFF;
  --color-ink: #2A2723;
  --color-muted: #8A8378;
  --color-accent: #6E2A33;
  --color-accent-soft: #F3E6E4;
  --color-line: #E2DED4;
  --color-warn-bg: #F6ECD9;
  --color-warn-text: #8A5A12;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;

  --radius: 10px;
  --sidebar-width: 230px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

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

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 0.75rem; }

.muted { color: var(--color-muted); }
.mono { font-family: var(--font-mono); }

/* ---------- Layout ---------- */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-line);
  padding: 1.75rem 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 2rem;
  color: var(--color-ink);
}
.brand .dot { color: var(--color-accent); }

.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-list li { margin-bottom: 0.15rem; }
.nav-list a {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  color: var(--color-ink);
  font-size: 0.92rem;
}
.nav-list a:hover { background: var(--color-bg); text-decoration: none; }
.nav-list a.active { background: var(--color-accent-soft); color: var(--color-accent); font-weight: 500; }

.content {
  flex: 1;
  padding: 2.5rem 3rem;
  max-width: 880px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin-bottom: 0.3rem;
}

/* Mobile top bar (sidebar collapses) */
.topbar { display: none; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { display: none; }

  .topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-line);
    padding: 0.9rem 1.25rem 0.6rem;
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .topbar .brand { margin-bottom: 0.6rem; }
  .topbar nav {
    display: flex;
    gap: 0.3rem;
    font-size: 0.82rem;
    flex-wrap: wrap;
    border-top: 1px solid var(--color-line);
    padding-top: 0.5rem;
  }
  .topbar nav a {
    padding: 0.3rem 0.5rem;
    border-radius: 5px;
    color: var(--color-ink);
  }
  .topbar nav a:hover { background: var(--color-bg); text-decoration: none; }
  .topbar nav form { display: inline; }
  .topbar nav .btn-logout {
    font-size: 0.82rem;
    padding: 0.3rem 0.5rem;
    width: auto;
    color: var(--color-muted);
  }

  .content { padding: 1.25rem 1rem; max-width: 100%; }

  h1 { font-size: 1.3rem; }

  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }

  .row-link { flex-wrap: wrap; gap: 0.5rem; }

  .form-actions { flex-wrap: wrap; }

  /* Tables scroll horizontally rather than overflowing */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.plain { min-width: 480px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .quick-modal { width: 95%; }
  .quick-modal-inner { padding: 1.25rem; }
  .quick-modal-actions { flex-direction: column; }
  .quick-modal-actions .btn { width: 100%; justify-content: center; }
}

/* ---------- Buttons & forms ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0.55rem 1rem;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--color-accent);
  color: #fff;
}
.btn:hover { background: #5a2129; text-decoration: none; }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-line);
}
.btn-secondary:hover { background: var(--color-bg); }

.btn-danger {
  background: var(--color-surface);
  color: #8a3a3a;
  border: 1px solid var(--color-line);
}
.btn-danger:hover { background: #fbeceb; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

form.inline { display: inline; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  margin-top: 1rem;
}
label:first-child { margin-top: 0; }

input[type=text], input[type=email], input[type=tel],
input[type=date], input[type=search], select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-line);
  border-radius: 7px;
  background: var(--color-surface);
  color: var(--color-ink);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.field-hint { font-size: 0.78rem; color: var(--color-muted); margin-top: 0.2rem; }

.form-actions {
  margin-top: 1.75rem;
  display: flex;
  gap: 0.6rem;
}

fieldset {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-top: 1rem;
}
fieldset legend {
  font-family: var(--font-display);
  font-size: 0.85rem;
  padding: 0 0.3rem;
  color: var(--color-muted);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--color-line);
}
.check-row:last-child { border-bottom: none; }
.check-row input[type=checkbox] { margin-top: 0.35rem; }
.check-row .check-body { flex: 1; }
.check-row .check-body input,
.check-row .check-body select,
.check-row .check-body textarea { margin-top: 0.4rem; }
.check-row .check-extra {
  display: none;
}
.check-row input[type=checkbox]:checked ~ .check-body .check-extra { display: block; }

/* ---------- Cards & lists ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
}

.card-list .card { margin-bottom: 0.75rem; }

.row-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.row-link h2, .row-link h3 { margin-bottom: 0.15rem; }

.empty-state {
  border: 1px dashed var(--color-line);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--color-muted);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  margin: 0 0.25rem 0.25rem 0;
}
.badge-warn { background: var(--color-warn-bg); color: var(--color-warn-text); }
.badge-muted { background: var(--color-bg); color: var(--color-muted); border: 1px solid var(--color-line); }

/* ---------- Stats (dashboard) ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat .stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-accent);
}
.stat .stat-label {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.2rem;
}

/* ---------- Dinner log entry (signature element) ---------- */

.log-number {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-accent);
  letter-spacing: 0.03em;
}

.log-entry {
  display: flex;
  gap: 1.1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-line);
}
.log-entry:last-child { border-bottom: none; }
.log-entry .log-marker {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-muted);
  width: 4.5rem;
  flex-shrink: 0;
  padding-top: 0.15rem;
}
.log-entry .log-body { flex: 1; }
.log-entry .log-body .date { font-size: 0.82rem; color: var(--color-muted); }

.course-block { margin-top: 1.25rem; }
.course-block h3 { color: var(--color-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.course-block ul { list-style: none; padding: 0; margin: 0; }
.course-block li { padding: 0.4rem 0; border-bottom: 1px solid var(--color-line); }
.course-block li:last-child { border-bottom: none; }

.list-row { padding: 0.6rem 0; border-bottom: 1px solid var(--color-line); }
.list-row:last-child { border-bottom: none; }

.note {
  font-size: 0.88rem;
  color: var(--color-ink);
  background: var(--color-bg);
  border-left: 3px solid var(--color-accent);
  padding: 0.5rem 0.75rem;
  border-radius: 0 6px 6px 0;
  margin-top: 0.4rem;
}

table.plain { width: 100%; border-collapse: collapse; }
table.plain th, table.plain td {
  text-align: left;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--color-line);
  font-size: 0.9rem;
}
table.plain th { color: var(--color-muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Sidebar footer / logout ---------- */

.nav-list { flex: 1; }
.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--color-line);
}
.btn-logout {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--color-muted);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  width: 100%;
  text-align: left;
}
.btn-logout:hover { background: var(--color-bg); color: var(--color-ink); }

/* ---------- Login page ---------- */

.login-page {
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-wrap {
  width: 100%;
  max-width: 360px;
  padding: 1.5rem;
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 2rem 2rem 2rem;
}
.login-error {
  background: #fbeceb;
  color: #8a3a3a;
  border: 1px solid #e8bfbf;
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

/* ---------- Dinner form: add-new button & course labels ---------- */

.btn-add-new {
  background: none;
  border: 1px dashed var(--color-line);
  border-radius: 7px;
  color: var(--color-muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
  margin-top: 0.75rem;
  width: 100%;
  text-align: center;
}
.btn-add-new:hover { border-color: var(--color-accent); color: var(--color-accent); background: var(--color-accent-soft); }

.check-course-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  margin: 0.85rem 0 0;
}

/* ---------- Quick-add modal ---------- */

.quick-modal {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 0;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.quick-modal::backdrop {
  background: rgba(42, 39, 35, 0.45);
}
.quick-modal-inner {
  padding: 1.75rem 1.75rem 1.5rem;
}
.quick-modal-inner h2 { margin-bottom: 1.25rem; }
.quick-modal-inner label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 1rem;
  margin-bottom: 0;
}
.quick-modal-inner label:first-of-type { margin-top: 0; }
.quick-modal-inner input,
.quick-modal-inner select,
.quick-modal-inner textarea { margin-top: 0.3rem; }
.quick-modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.quick-modal-error {
  background: #fbeceb;
  color: #8a3a3a;
  border: 1px solid #e8bfbf;
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
