/* Fonts served from this app (SIL Open Font License, see /fonts/LICENSE-*.txt). */
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/inter-latin-700-normal.woff2") format("woff2"); }

/* Eighteen Pies — Admin Dashboard styles (reuses the storefront's brand tokens) */

:root {
  --cream: #faf6ef;
  --ivory: #fffdf9;
  --white: #ffffff;
  --ink: #262220;
  --soft: #6b625a;
  --wine: #641e29;
  --wine-deep: #4d1620;
  --wine-pale: #f5e8ea;
  --gold: #b3803f;
  --gold-pale: #f3e8d3;
  --border: #ece3d2;
  --border-strong: #ddccae;
  --success: #5c7a4f;
  --success-pale: #e6ede2;
  --error: #a3403a;
  --error-pale: #f7e6e4;
  --radius-sm: 4px;
  --radius-md: 8px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 14px;
}

h1, h2, h3 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; margin: 0; color: var(--ink); }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 40px 32px;
  box-shadow: 0 12px 40px rgba(38, 34, 32, 0.08);
}
.login-logo {
  text-align: center;
  margin-bottom: 8px;
  font-family: "Times New Roman", serif;
  font-style: italic;
  font-size: 32px;
  color: var(--wine);
}
.login-tagline {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 28px;
}
.login-title { text-align: center; font-size: 15px; color: var(--ink); margin-bottom: 24px; font-weight: 600; font-family: inherit; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--soft); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--ivory);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--gold); border-color: transparent; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn--primary { background: var(--wine); color: var(--white); }
.btn--primary:hover { background: var(--wine-deep); }
.btn--secondary { background: transparent; border-color: var(--border-strong); color: var(--ink); }
.btn--secondary:hover { background: var(--gold-pale); }
.btn--ghost { background: none; color: var(--soft); }
.btn--ghost:hover { color: var(--wine); }
.btn--sm { padding: 6px 12px; font-size: 12px; }
.btn--full { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.login-error {
  background: var(--error-pale);
  color: var(--error);
  font-size: 12.5px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: none;
}
.login-error.is-visible { display: block; }
.login-hint { margin-top: 18px; text-align: center; font-size: 11.5px; color: var(--soft); }

/* ---------- App shell ---------- */
.app-shell { display: none; min-height: 100vh; }
.app-shell.is-visible { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo {
  font-family: "Times New Roman", serif;
  font-style: italic;
  font-size: 22px;
  color: var(--wine);
  text-align: center;
  margin-bottom: 2px;
}
.sidebar-tagline {
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 28px;
}
.nav-list { list-style: none; margin: 0; padding: 0; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--soft);
  font-weight: 500;
  margin-bottom: 2px;
  font-size: 13.5px;
}
.nav-item:hover { background: var(--cream); color: var(--ink); }
.nav-item.is-active { background: var(--wine-pale); color: var(--wine); font-weight: 700; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 14px; }
.sidebar-user { font-size: 12.5px; color: var(--soft); margin-bottom: 10px; }
.sidebar-user strong { display: block; color: var(--ink); font-size: 13px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 60px;
}
.page-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title-row h1 { font-size: 26px; }
.page-subtitle { color: var(--soft); font-size: 13px; margin-top: 4px; }

.view { display: none; }
.view.is-active { display: block; }

/* ---------- Cards / KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.kpi-card .kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--soft); font-weight: 600; margin-bottom: 8px; }
.kpi-card .kpi-value { font-size: 24px; font-weight: 700; color: var(--ink); }
.kpi-card .kpi-value.alert { color: var(--error); }
.kpi-card .kpi-sub { font-size: 12px; color: var(--soft); margin-top: 4px; }

.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  margin-bottom: 24px;
}
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.panel-header h2 { font-size: 17px; }

/* ---------- Orders view toggle + Kanban ---------- */
.view-toggle { display: flex; border: 1px solid var(--border-strong); border-radius: var(--radius-md); overflow: hidden; margin-left: auto; }
.view-toggle__btn { padding: 8px 14px; background: var(--white); border: none; border-left: 1px solid var(--border-strong); color: var(--soft); font: inherit; font-size: 13px; cursor: pointer; }
.view-toggle__btn:first-child { border-left: none; }
.view-toggle__btn.is-active { background: var(--gold-pale); color: var(--ink); font-weight: 600; }

.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { flex: 0 0 240px; background: var(--cream); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px; }
.kanban-column__header { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.kanban-column__count { color: var(--soft); font-weight: 400; }
.kanban-card { display: block; width: 100%; text-align: left; background: var(--white); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 6px; padding: 9px; margin-bottom: 8px; cursor: pointer; font: inherit; }
.kanban-card strong { display: block; font-size: 13px; margin-bottom: 3px; }
.kanban-card small { display: block; color: var(--soft); font-size: 11.5px; overflow-wrap: anywhere; }
.kanban-empty { color: var(--soft); font-size: 12px; padding: 6px 4px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--soft); padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.empty-row td { text-align: center; color: var(--soft); padding: 32px 10px; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.badge--awaiting_payment { background: var(--gold-pale); color: var(--gold); }
.badge--payment_submitted { background: #e4e9f2; color: #3a5a9c; }
.badge--payment_confirmed { background: var(--success-pale); color: var(--success); }
.badge--preparing { background: #eee6f5; color: #6b4a9c; }
.badge--ready { background: var(--gold-pale); color: #8a5a1c; }
.badge--shipped { background: #dff0f5; color: #2b7996; }
.badge--delivered { background: var(--success-pale); color: var(--success); }
.badge--delivery_failed { background: var(--error-pale); color: var(--error); }
.badge--cancelled { background: var(--error-pale); color: var(--error); }
.badge--active { background: var(--success-pale); color: var(--success); }
.badge--inactive { background: var(--error-pale); color: var(--error); }
.badge--lowstock { background: var(--error-pale); color: var(--error); }
.badge--instock { background: var(--success-pale); color: var(--success); }

.inline-input {
  width: 90px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--ivory);
}
.inline-input:focus { outline: 2px solid var(--gold); border-color: transparent; }
.save-hint { font-size: 11px; color: var(--success); margin-left: 8px; opacity: 0; transition: opacity 0.2s; }
.save-hint.is-visible { opacity: 1; }

select.status-select {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  background: var(--ivory);
}

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type="text"], .toolbar input[type="date"], .toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--white);
}

/* ---------- Modal (order detail) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(38, 34, 32, 0.45);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.is-open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius-md); max-width: 560px; width: 100%;
  max-height: 86vh; overflow-y: auto; padding: 28px;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--soft); line-height: 1; }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.detail-row dt { color: var(--soft); }
.detail-row dd { margin: 0; font-weight: 600; text-align: right; }
.section-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--soft); font-weight: 700; margin: 18px 0 8px; }

/* ---------- Simple bar chart ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar { width: 100%; max-width: 22px; background: var(--wine); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-chart .bar-label { font-size: 9px; color: var(--soft); margin-top: 6px; white-space: nowrap; }
.chart-empty { color: var(--soft); font-size: 13px; padding: 40px 0; text-align: center; }

/* ---------- Mobile hamburger ---------- */
.mobile-topbar { display: none; }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -100%; z-index: 90; transition: left 0.2s; box-shadow: 0 0 0 9999px rgba(0,0,0,0); }
  .sidebar.is-open { left: 0; box-shadow: 0 0 0 9999px rgba(0,0,0,0.35); }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; background: var(--white); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
  }
  .app-shell { flex-direction: column; }
  .main { padding: 20px 18px 60px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--white); padding: 12px 22px; border-radius: 999px;
  font-size: 13px; z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.toast.is-visible { opacity: 1; }

/* Products / Users: forms, grids, danger buttons */
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; min-width: 0; }
.muted { color: var(--soft); font-weight: 400; }
.btn--danger { background: var(--error-pale); color: var(--error); border-color: transparent; }
.btn--danger:hover { background: var(--error); color: var(--white); }
.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 16px;
}
.checkbox-field input { width: 16px; height: 16px; accent-color: var(--wine); }
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px 16px;
  padding: 12px 14px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.modal-footer { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.modal { max-height: 88vh; overflow-y: auto; }
.permission-chip {
  display: inline-block;
  padding: 2px 9px;
  margin: 0 4px 4px 0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--gold-pale);
  color: var(--wine-deep);
}
.permission-chip--owner { background: var(--wine); color: var(--white); }

/* ============================ New-order alert ============================ */
.order-alert {
  display: none; position: fixed; inset: 0; z-index: 300;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(176, 30, 30, 0.35);
}
.order-alert.is-visible { display: flex; }
.order-alert-box {
  background: var(--white); border-radius: 12px; padding: 28px 24px; max-width: 360px; width: 100%;
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.35);
  animation: order-alert-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes order-alert-pulse {
  from { box-shadow: 0 10px 40px rgba(176,30,30,0.25); }
  to   { box-shadow: 0 10px 55px rgba(176,30,30,0.65); }
}
.order-alert-icon { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.order-alert-title { font-size: 19px; font-weight: 700; color: #b01e1e; margin-bottom: 10px; }
.order-alert-detail { font-size: 14px; color: var(--ink); margin-bottom: 18px; white-space: pre-line; }
.order-alert-box .btn { background: #b01e1e; border-color: #b01e1e; color: var(--white); }
.order-alert-box .btn:hover { background: #8e1818; }
