/* ==========================================================
   Meat Order System — Design tokens
   Palette: warm butcher-paper cream, charcoal ink, brick-red
   accent, brass stamp accent. Type: Oswald (condensed display,
   signage feel) + Karla (body). Layout reads like an order
   ticket / chalkboard menu rather than a generic SaaS card grid.
   ========================================================== */

:root {
  --paper: #f3ede0;
  --paper-2: #ece3d1;
  --ink: #211d18;
  --ink-soft: #57503f;
  --brick: #8c2f22;
  --brick-dark: #6e2419;
  --brass: #a97a35;
  --brass-light: #f1e2c4;
  --line: #d8cca8;
  --card: #fffdf8;
  --danger: #a13b2b;
  --shadow: 0 2px 10px rgba(33, 29, 24, 0.08);
  --shadow-lg: 0 14px 30px rgba(33, 29, 24, 0.18);
}

body.dark-mode {
  --paper: #17140f;
  --paper-2: #1f1a13;
  --ink: #f3ede0;
  --ink-soft: #c8bda1;
  --card: #241f17;
  --line: #3a3123;
  --brass-light: rgba(169, 122, 53, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Karla', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  transition: background-color .3s, color .3s;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .display {
  font-family: 'Oswald', sans-serif;
  text-transform: none;
  letter-spacing: 0.01em;
}

.app-wrapper { max-width: 980px; margin: 0 auto; padding-bottom: 190px; }

/* ---------- Header ---------- */
header.top-band {
  background: var(--ink);
  color: var(--paper);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--brick);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--brick);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; border: 2px solid var(--brass-light);
  flex-shrink: 0;
}
.brand-title { font-size: 1.3rem; font-weight: 700; color: var(--paper); line-height: 1.1; }
.brand-sub { font-size: 0.72rem; color: var(--brass-light); font-family: 'Karla', sans-serif; letter-spacing: 0.04em; margin-top: 2px; }

.header-actions { display: flex; gap: 8px; align-items: center; }
.btn-icon, .btn-admin, .btn-brick {
  font-family: 'Karla', sans-serif; cursor: pointer; transition: all .2s;
}
.btn-icon {
  background: rgba(255,255,255,0.08); color: var(--paper);
  border: 1px solid rgba(255,255,255,0.2); width: 38px; height: 38px;
  border-radius: 8px; font-size: 1.05rem; display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: rgba(255,255,255,0.18); }
.btn-admin {
  background: var(--brass); color: var(--ink); border: none;
  padding: 9px 16px; border-radius: 8px; font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; gap: 6px; text-decoration: none;
}
.btn-admin:hover { background: #bf9047; }

/* ---------- Controls ---------- */
.control-panel {
  background: var(--paper-2);
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 78px; z-index: 99;
}
.search-input {
  width: 100%; padding: 11px 16px; border: 1.5px solid var(--line); border-radius: 8px;
  font-size: 0.92rem; outline: none; background: var(--card); color: var(--ink);
  font-family: 'Karla', sans-serif; margin-bottom: 10px;
}
.search-input:focus { border-color: var(--brick); }

.tabs-container { display: none; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.tabs-container::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 7px 16px; border-radius: 999px; background: var(--card); color: var(--ink-soft);
  border: 1px solid var(--line); font-weight: 700; font-size: 0.8rem; white-space: nowrap; cursor: pointer;
}
.tab-btn.active { background: var(--brick); color: #fff; border-color: var(--brick); }

.mobile-cat-wrapper { display: block; position: relative; }
.btn-mobile-cat {
  width: 100%; background: var(--card); color: var(--ink); border: 1.5px solid var(--brick);
  padding: 10px 14px; border-radius: 8px; font-weight: 700; font-size: 0.9rem; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; font-family: 'Karla', sans-serif;
}
.mobile-cat-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); z-index: 150; max-height: 300px; overflow-y: auto;
}
.mobile-cat-dropdown.open { display: block; }
.mobile-cat-item { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 0.88rem; cursor: pointer; display: flex; justify-content: space-between; }
.mobile-cat-item:last-child { border-bottom: none; }
.mobile-cat-item.active { background: var(--brass-light); color: var(--brick); font-weight: 800; }

@media (min-width: 651px) {
  .tabs-container { display: flex; }
  .mobile-cat-wrapper { display: none; }
}

/* ---------- Category sections: ticket style ---------- */
.container { padding: 18px 20px; }
.category-section { margin-bottom: 26px; }

.category-header-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px 8px 0; margin-bottom: 12px;
  border-bottom: 2px dashed var(--line);
}
.category-title-text { font-family: 'Oswald', sans-serif; font-size: 1.15rem; font-weight: 600; color: var(--ink); }
.cat-count-pill {
  font-size: 0.72rem; font-weight: 700; color: var(--brick); background: var(--brass-light);
  padding: 3px 11px; border-radius: 999px; white-space: nowrap; font-family: 'Karla', sans-serif;
}

.items-grid { display: flex; flex-direction: column; gap: 8px; }

.item-card {
  background: var(--card); padding: 12px 14px; border-radius: 6px;
  border: 1px solid var(--line); border-left: 4px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow); transition: border-color .2s, background .2s;
}
.item-card.has-qty { border-left-color: var(--brick); background: var(--brass-light); }
.item-name { font-weight: 600; font-size: 0.92rem; color: var(--ink); flex: 1; word-break: break-word; }

.qty-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-qty {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 1rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn-qty:active { transform: scale(0.92); }
.btn-minus { color: var(--danger); }
.btn-plus { color: var(--brick); border-color: var(--brick); }
.qty-val {
  min-width: 26px; height: 26px; text-align: center; font-weight: 700; font-size: 0.9rem;
  color: #fff; background: var(--brick); border-radius: 50%; display: flex; align-items: center; justify-content: center;
}

@media (min-width: 651px) {
  .items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .item-card { flex-direction: column; text-align: center; border-left-width: 1px; border-top: 4px solid var(--line); min-height: 108px; justify-content: space-between; padding: 12px 8px; }
  .item-card.has-qty { border-top-color: var(--brick); }
  .item-name { font-size: 0.82rem; }
}

/* ---------- Footer bar ---------- */
.footer-bar-wrapper {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  padding: 12px 16px; background: var(--ink); border-top: 3px solid var(--brick);
}
.footer-bar { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.notes-input {
  width: 100%; padding: 9px 12px; border: 1px solid rgba(255,255,255,0.2); border-radius: 6px;
  font-size: 0.85rem; outline: none; background: rgba(255,255,255,0.06); color: var(--paper);
  font-family: 'Karla', sans-serif;
}
.notes-input::placeholder { color: rgba(243,237,224,0.5); }
.order-summary-badge { font-size: 0.8rem; font-weight: 700; color: var(--brass-light); text-align: center; display: flex; justify-content: center; gap: 6px; }
.order-summary-badge span { background: var(--brick); color: #fff; padding: 2px 12px; border-radius: 999px; }

.action-btns { display: flex; gap: 8px; }
.btn-share-main, .btn-copy, .btn-reset {
  border: none; padding: 12px; border-radius: 8px; font-weight: 700; font-size: 0.9rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; font-family: 'Karla', sans-serif;
}
.btn-share-main { flex: 2; background: var(--brick); color: #fff; }
.btn-share-main:hover { background: var(--brick-dark); }
.btn-copy { flex: 1; background: var(--brass); color: var(--ink); }
.btn-reset { flex: 1; background: transparent; color: var(--paper); border: 1px solid rgba(255,255,255,0.25); }
.btn-reset:hover { border-color: var(--danger); color: #f2a89e; }

/* ---------- Modals (share modal on customer page) ---------- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(20,17,12,0.65); z-index: 200; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--card); color: var(--ink); border-radius: 12px; width: 100%; max-width: 580px;
  max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg);
}
.modal-header { background: var(--ink); color: var(--paper); padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-family: 'Oswald', sans-serif; font-size: 1.05rem; font-weight: 600; }
.btn-close { background: rgba(255,255,255,0.1); border: none; color: var(--paper); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

.share-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.btn-share-option { padding: 14px 16px; border-radius: 8px; border: 1px solid var(--line); font-weight: 700; font-size: 0.92rem; cursor: pointer; display: flex; align-items: center; gap: 10px; background: var(--card); color: var(--ink); }
.btn-share-option.wa { background: #25d366; color: #fff; border: none; }
.btn-share-option.sms { background: #16a34a; color: #fff; border: none; }
.btn-share-option.email { background: #d64535; color: #fff; border: none; }
.btn-share-option.native { background: var(--brick); color: #fff; border: none; grid-column: span 2; justify-content: center; }

/* ---------- Auth pages (login / create_admin) ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--brick);
  border-radius: 10px; max-width: 400px; width: 100%; padding: 28px 26px; box-shadow: var(--shadow-lg);
}
.auth-card .brand-title { color: var(--ink); margin-bottom: 18px; font-size: 1.25rem; }
.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form label { font-size: 0.82rem; font-weight: 700; color: var(--ink-soft); margin-top: 10px; }
.auth-form input {
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 6px; font-size: 0.92rem;
  outline: none; font-family: 'Karla', sans-serif; background: var(--paper); color: var(--ink);
}
.auth-form input:focus { border-color: var(--brick); }
.btn-brick {
  margin-top: 18px; background: var(--brick); color: #fff; border: none; padding: 11px; border-radius: 6px;
  font-weight: 700; font-size: 0.92rem; cursor: pointer; text-align: center; text-decoration: none;
  font-family: 'Karla', sans-serif; display: block;
}
.btn-brick:hover { background: var(--brick-dark); }
.auth-note { font-size: 0.85rem; margin-bottom: 6px; line-height: 1.5; }
.auth-note.err { color: var(--danger); font-weight: 700; }
.auth-note.ok { color: #2e7d4f; font-weight: 700; }
.auth-note.warn { color: var(--brass); }

/* ---------- Admin dashboard page ---------- */
.admin-add-box { background: var(--paper-2); border: 1px solid var(--line); padding: 14px; border-radius: 10px; margin-bottom: 14px; }
.admin-add-box h3 { font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 8px; font-weight: 700; letter-spacing: 0.03em; font-family: 'Karla', sans-serif; }
.add-form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form-row input, .add-form-row select {
  flex: 1; min-width: 140px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 0.88rem; outline: none; background: var(--card); color: var(--ink); font-family: 'Karla', sans-serif;
}
.btn-submit-add { background: var(--brick); color: #fff; border: none; padding: 10px 18px; border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 0.88rem; }

.admin-cat-header {
  display: flex; justify-content: space-between; align-items: center; background: var(--brass-light);
  padding: 9px 12px; border-radius: 6px; margin: 16px 0 6px; font-weight: 700; font-size: 0.88rem;
  color: var(--ink); cursor: grab; border: 1px solid var(--line);
}
.cat-title-group { display: flex; align-items: center; gap: 8px; }
.drag-handle { color: var(--ink-soft); font-size: 1.05rem; cursor: grab; }
.cat-actions { display: flex; gap: 4px; align-items: center; }

.btn-reorder { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 5px; width: 26px; height: 26px; font-size: 0.72rem; cursor: pointer; }
.btn-reorder:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-del-cat { background: var(--danger); color: #fff; border: none; padding: 4px 8px; border-radius: 5px; font-size: 0.7rem; cursor: pointer; font-weight: 600; margin-left: 4px; }

.admin-item-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 4px; font-size: 0.88rem; gap: 8px; flex-wrap: wrap; }
.admin-item-actions { display: flex; gap: 6px; align-items: center; }
.select-move { background: var(--paper-2); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; font-size: 0.75rem; outline: none; cursor: pointer; font-weight: 600; color: var(--ink-soft); max-width: 110px; }

.btn-edit { background: var(--brass); color: var(--ink); border: none; padding: 5px 10px; border-radius: 5px; font-size: 0.75rem; cursor: pointer; font-weight: 700; }
.btn-delete { background: var(--danger); color: #fff; border: none; padding: 5px 10px; border-radius: 5px; font-size: 0.75rem; cursor: pointer; font-weight: 700; }

.sync-status { font-size: 0.74rem; color: #7bc596; font-weight: 600; }
.sync-status.err { color: #e0796b; }

.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.admin-user-pill { font-size: 0.8rem; color: var(--ink-soft); }
.link-logout { color: var(--brick); font-weight: 700; text-decoration: none; font-size: 0.85rem; }
