/* Savour — shared theme.
   Rustic kitchen palette: deep moss, burnt brick, warm mustard, raw linen. */

:root {
  --bg: #EFE9DA;
  --surface: #FBF8F1;
  --surface-2: #F3EDDD;
  --line: #DDD3BC;
  --muted: #7A7263;
  --text: #2B2620;

  --accent: #4B5D32;
  --accent-dark: #33401F;
  --accent-soft: #E3E7D6;
  --on-light-chip: #33401F; /* fixed dark text for chips with a constant light/white background, regardless of theme */

  --rust: #A8462A;
  --rust-dark: #7C3220;
  --rust-soft: #F3E0D8;

  --gold: #C08A28;
  --gold-dark: #8C6415;
  --gold-soft: #F5E9D2;

  --danger: #A8462A;
  --danger-soft: #F3E0D8;
  --success: #4B5D32;
  --success-soft: #E3E7D6;

  --radius: 14px;
  --sidebar-width: 236px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #211D18;
  --surface: #2B2620;
  --surface-2: #342E27;
  --line: #453E34;
  --muted: #A79A87;
  --text: #F1EAD9;

  --accent: #8FAE63;
  --accent-dark: #C4DBA6;
  --accent-soft: #3A4530;

  --rust: #E4926E;
  --rust-dark: #F2C1A9;
  --rust-soft: #4A2A1F;

  --gold: #E8B85C;
  --gold-dark: #F5D48F;
  --gold-soft: #4A3A17;

  --danger: #E4926E;
  --danger-soft: #4A2A1F;
  --success: #8FAE63;
  --success-soft: #3A4530;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color .15s ease, color .15s ease;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }
p { line-height: 1.5; }

a { color: var(--accent-dark); }

/* ---------- App shell ---------- */

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

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

.sidebar-top-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; padding: 0 4px; }
.sidebar-top-btns { display: flex; gap: 6px; flex-shrink: 0; }
.sidebar-logo { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.sidebar-logo svg { flex-shrink: 0; }
.sidebar-logo-text { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--text); }
.sidebar-collapse-btn { background: transparent; border: 1px solid var(--line); border-radius: 8px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; color: var(--muted); cursor: pointer; flex-shrink: 0; }
.sidebar-collapse-btn:hover { background: var(--surface-2); color: var(--text); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.sidebar-nav a:hover { background: var(--surface-2); }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent-dark); }
.sidebar-nav .icon { font-size: 16px; width: 20px; text-align: center; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-nav .icon svg { display: block; }

.sidebar-extra-link { display: block; padding: 8px 10px; font-size: 13px; color: var(--muted); text-decoration: none; border-radius: 8px; }
.sidebar-extra-link:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Collapsed sidebar ---------- */
.sidebar.collapsed { width: 64px; padding: 20px 10px; }
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-profile-text,
.sidebar.collapsed .sidebar-admin-label,
.sidebar.collapsed .sidebar-extra-link,
.sidebar.collapsed #statusDotText {
  display: none;
}
.sidebar.collapsed .sidebar-top-row { flex-direction: column; gap: 10px; }
.sidebar.collapsed .sidebar-top-btns { flex-direction: column; }
.sidebar.collapsed .sidebar-nav a { justify-content: center; }
.sidebar.collapsed .sidebar-profile-btn { justify-content: center; gap: 0; }
.sidebar.collapsed .status-dot-row { justify-content: center; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

.sidebar-admin-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 14px 10px 4px;
}

.sidebar-profile {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}
.sidebar-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
}
.sidebar-profile-btn:hover { background: var(--surface-2); }
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; flex-shrink: 0;
  overflow: hidden;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-profile-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.sidebar-profile-plan { font-size: 11px; color: var(--muted); }

.status-dot-row {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px 0; font-size: 11px; color: var(--muted);
  cursor: default;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.ok { background: var(--accent); }
.status-dot.error { background: var(--rust); }

.app-main { flex: 1; min-width: 0; padding: 28px 32px; }

/* ---------- Mobile: top bar + floating popup menu ---------- */

.mobile-topbar { display: none; }
.mobile-menu-popup { display: none; }

@media (max-width: 880px) {
  .sidebar { display: none; }
  .app-shell { flex-direction: column; }
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
    position: sticky; top: 0; z-index: 20;
  }
  .mobile-topbar .sidebar-logo { margin-bottom: 0; }
  .mobile-menu-btn { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 18px; cursor: pointer; }
  .app-main { padding: 20px 16px 80px; }

  .mobile-menu-popup {
    display: none;
    position: fixed; inset: 0; z-index: 30;
    background: rgba(43,38,32,0.35);
  }
  .mobile-menu-popup.open { display: block; }
  .mobile-menu-sheet {
    background: var(--surface);
    border-radius: 0 0 18px 18px;
    padding: 16px;
    max-height: 85vh;
    overflow-y: auto;
  }
  .mobile-menu-sheet .sidebar-nav a { font-size: 15px; padding: 12px 10px; }
}

/* ---------- Shared components (used across every page) ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: background-color .15s ease, border-color .15s ease; }

.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.section-head h2 { font-size: 22px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 10px;
  padding: 9px 14px; font-size: 14px; font-family: var(--font-body);
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { background: var(--rust-soft); border-color: var(--rust-soft); color: var(--rust-dark); }
.btn.danger:hover { background: var(--rust); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

.status { position: fixed; bottom: 10px; right: 14px; font-size: 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; opacity: .7; }

.cover-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
}
.cover-placeholder svg { opacity: .55; }

.meta { color: var(--muted); }
.empty-state { color: var(--muted); text-align: center; padding: 30px; }

input, select, textarea {
  font-family: var(--font-body);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px;
  background: var(--surface);
  color: var(--text);
}
