/* ── Admin — The Roaster's Notebook ───────────────────────────────────── */
/*
  Same token system as the main site — editorial, clean, light.
  Coffee Cherry (#C44D34) added as secondary accent for destructive actions.
*/

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

:root {
  --paper: #F4F2EC;
  --roast: #1B1512;
  --roast-med: #4A4038;
  --parchment: #968878;
  --green: #3C6E55;
  --green-light: #4E8A6B;
  --cherry: #C44D34;
  --cherry-bg: rgba(196, 77, 52, 0.06);
  --crema: #EAE5DD;
  --white: #FFFFFF;
  --rule: #D9D2C7;
  --rule-light: #EBE7E0;
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-body: 'Figtree', -apple-system, BlinkMacSystemFont, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

html {
  background: var(--paper);
  color: var(--roast);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--paper);
  min-height: 100vh;
}

::selection { background: rgba(60, 110, 85, 0.12); color: var(--roast); }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
}

.login-card {
  background: var(--white);
  border: 1px solid var(--rule);
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-overline {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--parchment);
  margin-bottom: 8px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--roast);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.login-card > p {
  font-size: 0.82rem;
  color: var(--roast-med);
  margin-bottom: 28px;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--roast);
  background: var(--paper);
  transition: border-color 0.2s var(--ease);
  margin-bottom: 6px;
}

.login-card input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(60, 110, 85, 0.08);
}

.login-error {
  font-size: 0.75rem;
  color: var(--cherry);
  min-height: 18px;
  margin: 4px 0 16px;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease),
              border-color 0.2s var(--ease);
  border: none;
  letter-spacing: 0.01em;
  text-decoration: none;
  background: var(--roast);
  color: var(--paper);
}

.btn:hover { background: var(--green); }

.btn:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  color: var(--roast-med);
  border: 1px solid var(--rule);
}

.btn-ghost:hover {
  background: transparent;
  border-color: var(--roast-med);
  color: var(--roast);
}

.btn-danger {
  background: transparent;
  color: var(--cherry);
  border: 1px solid transparent;
}

.btn-danger:hover {
  background: var(--cherry-bg);
  border-color: var(--cherry);
}

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(244, 242, 236, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  padding: 0;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 36px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 32px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--roast);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.topbar-logo:hover { color: var(--green); }

.topbar-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--parchment);
  padding: 2px 8px;
  border: 1px solid var(--rule);
}

.topbar-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.tb-nav-item {
  padding: 6px 14px;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--roast-med);
  cursor: pointer;
  transition: color 0.2s;
  letter-spacing: 0.02em;
}

.tb-nav-item:hover { color: var(--roast); }

.tb-nav-item.active {
  color: var(--green);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 16px;
  align-items: center;
}

.topbar-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--roast-med);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  transition: color 0.2s;
  letter-spacing: 0.02em;
}

.topbar-link:hover { color: var(--green); }

/* ── Main ──────────────────────────────────────────────────────────────── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 36px 80px;
}

.panel {
  animation: panelIn 0.3s var(--ease);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.panel-head h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--roast);
  letter-spacing: -0.01em;
}

/* ── Table ─────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--rule);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--parchment);
  padding: 12px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.table td {
  padding: 14px 20px;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--rule-light);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: var(--paper); }

.item-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-thumb {
  width: 40px;
  height: 40px;
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.item-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.item-thumb svg {
  width: 18px;
  height: 18px;
  color: var(--parchment);
  opacity: 0.7;
  position: relative;
  z-index: 0;
}

.item-name {
  font-weight: 600;
  color: var(--roast);
}

.item-desc {
  font-size: 0.72rem;
  color: var(--parchment);
  margin-top: 2px;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 10px;
}

.badge-available { color: var(--green); }
.badge-soldout { color: var(--cherry); }

.actions {
  display: flex;
  gap: 4px;
}

.act {
  width: 32px;
  height: 32px;
  border: 1px solid var(--rule-light);
  background: var(--white);
  cursor: pointer;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.act:hover { background: var(--paper); border-color: var(--rule); }
.act.danger:hover { background: var(--cherry-bg); border-color: var(--cherry); }

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--parchment);
  font-size: 0.85rem;
}

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-block {
  background: var(--white);
  border: 1px solid var(--rule);
  padding: 32px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--parchment);
  margin-bottom: 24px;
  max-width: 480px;
}

.form-subhead {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--roast);
  margin-top: 28px;
  margin-bottom: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--parchment);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  font-family: var(--font-body);
  font-size: 0.84rem;
  color: var(--roast);
  background: var(--paper);
  transition: border-color 0.2s var(--ease);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(60, 110, 85, 0.07);
}

.field input::placeholder,
.field textarea::placeholder { color: var(--parchment); }

.field select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23968878' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.field-checks {
  display: flex;
  gap: 28px;
  margin-bottom: 20px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--roast);
}

.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
  cursor: pointer;
}

.form-error { font-size: 0.78rem; color: var(--cherry); margin-bottom: 12px; }
.form-success { font-size: 0.78rem; color: var(--green); margin-bottom: 12px; }

/* ── Category Editor ───────────────────────────────────────────────────── */
.cat-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.cat-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cat-row input {
  padding: 9px 12px;
  border: 1px solid var(--rule);
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--roast);
  background: var(--paper);
  transition: border-color 0.2s;
}

.cat-row input:focus {
  outline: none;
  border-color: var(--green);
}

.cat-icon { width: 56px; text-align: center; }
.cat-name { flex: 1; }

.cat-remove {
  width: 32px;
  height: 32px;
  border: 1px solid var(--rule-light);
  background: var(--white);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--cherry);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.cat-remove:hover { background: var(--cherry-bg); border-color: var(--cherry); }

/* ── Hours Editor ──────────────────────────────────────────────────────── */
.hours-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.hours-row input {
  padding: 9px 12px;
  border: 1px solid var(--rule);
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--roast);
  background: var(--paper);
  transition: border-color 0.2s;
}

.hours-row input:focus { outline: none; border-color: var(--green); }
.hours-days { flex: 1; }
.hours-time { flex: 1.5; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(27, 21, 18, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open { display: flex; }

.modal-card {
  background: var(--white);
  border: 1px solid var(--rule);
  width: 100%;
  max-width: 500px;
  max-height: 88vh;
  overflow-y: auto;
  animation: modalIn 0.25s var(--ease);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 0;
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--roast);
  letter-spacing: -0.01em;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 1.3rem;
  color: var(--parchment);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--roast); }

.modal-card form { padding: 20px 28px 28px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

/* ── QR Grid ──────────────────────────────────────────────────────────── */
.qr-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  background: var(--white);
  border: 1px solid var(--rule);
  padding: 28px;
}

.qr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--rule-light);
  background: var(--paper);
}

.qr-card img {
  display: block;
  border: 1px solid var(--rule-light);
}

.qr-label {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--roast);
}

.qr-url {
  font-size: 0.6rem;
  color: var(--parchment);
  word-break: break-all;
  max-width: 150px;
  text-align: center;
  line-height: 1.3;
}

/* ── Order Cards ─────────────────────────────────────────────────────── */
.order-card {
  background: var(--white);
  border: 1px solid var(--rule);
  margin-bottom: 12px;
}

.order-card.order-cancelled {
  opacity: 0.5;
  background: var(--paper);
}

.order-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule-light);
}

.order-tbl {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--roast);
  margin-right: 12px;
}

.order-time {
  font-size: 0.72rem;
  color: var(--parchment);
}

.order-card-body {
  padding: 16px 20px;
}

.order-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.order-items li {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--roast);
  padding: 4px 0;
}

.order-items li span {
  font-weight: 600;
  color: var(--roast-med);
}

.order-item-custom {
  font-style: italic;
  color: var(--parchment) !important;
}

.order-note {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--parchment);
  font-style: italic;
  padding-top: 8px;
  border-top: 1px solid var(--rule-light);
}

.order-total {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--green);
  text-align: right;
}

.order-card-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--rule-light);
}

.order-card-actions .btn {
  font-size: 0.75rem;
  padding: 8px 16px;
}

.order-card-actions .btn.serve {
  background: var(--green);
  color: var(--white);
}

.order-card-actions .btn.serve:hover { background: var(--green-light); }

.order-card-actions .btn.paid {
  background: var(--roast);
  color: var(--paper);
}

.order-card-actions .btn.cancel {
  border-color: var(--cherry);
  color: var(--cherry);
}

.order-card-actions .btn.cancel:hover {
  background: var(--cherry-bg);
  border-color: var(--cherry);
}

.badge-order-new { color: var(--green); }
.badge-order-served { color: var(--roast-med); }
.badge-order-paid { color: var(--parchment); }
.badge-order-cancelled { color: var(--cherry); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--white);
  border: 1px solid var(--rule);
  padding: 12px 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--roast);
  z-index: 300;
  animation: toastIn 0.3s var(--ease);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--cherry); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Reduced Motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar-inner { padding: 0 20px; flex-wrap: wrap; height: auto; padding: 12px 20px; gap: 12px; }
  .topbar-nav { order: 3; width: 100%; overflow-x: auto; }
  .main { padding: 24px 20px 60px; }

  .field-row { grid-template-columns: 1fr; }

  .table { font-size: 0.78rem; }
  .table th, .table td { padding: 10px 12px; }
  .actions { flex-direction: column; }

  .modal-card { max-width: 100%; }
}
