/* ==========================================================================
   BUKAL BREW COFFEE — admin panel
   Same palette as the shop, darker and denser. Built for a phone screen as
   much as a desktop, because most of this gets used behind the counter.
   ========================================================================== */

:root {
  --bean:   #1E120C;
  --bean-2: #2A1A11;
  --bean-3: #3A2618;
  --crema:  #F3E7D3;
  --honey:  #C8912F;
  --honey-2:#E0B45C;
  --leaf:   #4E8A55;
  --cherry: #C4463A;
  --line:   rgba(243, 231, 211, .14);
  --muted:  rgba(243, 231, 211, .62);
}

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

body {
  margin: 0;
  background: var(--bean);
  color: var(--crema);
  font-family: "Karla", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15.5px;
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600; line-height: 1.15; margin: 0 0 .5em;
}
h1 { font-size: 1.72rem; }
h2 { font-size: 1.28rem; }
h3 { font-size: 1.05rem; }

a { color: var(--honey-2); }
img { max-width: 100%; display: block; }

:focus-visible { outline: 2.5px solid var(--honey); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- shell ---------------------------------------------------------------- */
.admin { display: grid; grid-template-columns: 254px 1fr; min-height: 100vh; }

.side {
  background: var(--bean-2);
  border-right: 1px solid var(--line);
  padding: 1.2rem 1rem;
  display: flex; flex-direction: column; gap: .2rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand { display: flex; gap: .7rem; align-items: center; margin-bottom: 1.4rem; text-decoration: none; color: inherit; }
.side-brand img { width: 44px; height: 44px; border-radius: 50%; }
.side-brand b { font-family: "Fraunces", serif; font-size: 1rem; display: block; line-height: 1.1; }
.side-brand span { font-size: .74rem; color: var(--muted); }

.side a.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .58rem .75rem; border-radius: 9px;
  color: var(--crema); text-decoration: none; font-size: .95rem; font-weight: 600;
}
.side a.nav-item:hover { background: rgba(243,231,211,.07); }
.side a.nav-item[aria-current="page"] { background: var(--honey); color: var(--bean); }
.side a.nav-item .tag {
  margin-left: auto; background: var(--cherry); color: #fff;
  border-radius: 999px; font-size: .7rem; padding: 0 .45rem; font-weight: 700;
}
.side-group { font-size: .72rem; color: var(--muted); padding: 1rem .75rem .3rem; letter-spacing: .06em; }
.side-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .84rem; color: var(--muted); }

.main { padding: 1.6rem clamp(1rem, 3vw, 2.2rem) 4rem; min-width: 0; }

.page-head {
  display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.6rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--line);
}
.page-head p { margin: 0; color: var(--muted); font-size: .93rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .6rem; flex-wrap: wrap; }

.topbar-mobile { display: none; }

@media (max-width: 940px) {
  .admin { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 258px; z-index: 90;
    transform: translateX(-100%); transition: transform .2s ease; height: 100vh;
  }
  .side.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .topbar-mobile {
    display: flex; align-items: center; gap: .8rem;
    padding: .7rem 1rem; background: var(--bean-2); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 70;
  }
  .topbar-mobile img { width: 34px; height: 34px; border-radius: 50%; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 85; }
}

/* --- cards and panels ------------------------------------------------------ */
.panel {
  background: var(--bean-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.3rem;
  margin-bottom: 1.3rem;
}
.panel > h2, .panel > h3 { margin-top: 0; }
.panel-note { color: var(--muted); font-size: .89rem; margin: -.3rem 0 1.1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.stat {
  background: var(--bean-2); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem;
}
.stat b { display: block; font-family: "Fraunces", serif; font-size: 1.95rem; line-height: 1.1; color: var(--honey-2); }
.stat span { font-size: .86rem; color: var(--muted); }
.stat.is-alert b { color: var(--cherry); }

/* --- tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data { width: 100%; border-collapse: collapse; font-size: .93rem; min-width: 640px; }
table.data th {
  text-align: left; font-size: .78rem; color: var(--muted); font-weight: 700;
  padding: .55rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: .7rem; border-bottom: 1px solid rgba(243,231,211,.07); vertical-align: top; }
table.data tr:hover td { background: rgba(243,231,211,.035); }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }

.cell-main { font-weight: 700; }
.cell-sub { color: var(--muted); font-size: .84rem; }

/* --- pills ----------------------------------------------------------------- */
.pill {
  display: inline-block; padding: .16rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap;
  background: rgba(243,231,211,.12); color: var(--crema);
}
.pill-pending    { background: rgba(200,145,47,.2);  color: var(--honey-2); }
.pill-confirmed  { background: rgba(200,145,47,.28); color: var(--honey-2); }
.pill-roasting   { background: rgba(196,70,58,.2);   color: #F0A398; }
.pill-ready      { background: rgba(78,138,85,.22);  color: #9BD3A2; }
.pill-delivering { background: rgba(78,138,85,.22);  color: #9BD3A2; }
.pill-completed  { background: rgba(78,138,85,.3);   color: #B6E3BC; }
.pill-cancelled  { background: rgba(243,231,211,.12); color: var(--muted); }
.pill-on         { background: rgba(78,138,85,.26);  color: #9BD3A2; }
.pill-off        { background: rgba(196,70,58,.22);  color: #F0A398; }

/* --- buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 700; font-size: .92rem;
  padding: .55rem 1.05rem; border: 1.5px solid transparent; border-radius: 999px;
  cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--honey); color: var(--bean); }
.btn-primary:hover { background: var(--honey-2); }
.btn-ghost { background: transparent; color: var(--crema); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--honey); color: var(--honey-2); }
.btn-danger { background: rgba(196,70,58,.16); color: #F0A398; border-color: rgba(196,70,58,.4); }
.btn-danger:hover { background: var(--cherry); color: #fff; }
.btn-sm { padding: .32rem .75rem; font-size: .84rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-row { display: flex; gap: .4rem; flex-wrap: wrap; }

/* --- forms ------------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 700; font-size: .87rem; margin-bottom: .3rem; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: .28rem; }

input[type=text], input[type=email], input[type=tel], input[type=number], input[type=url],
input[type=password], input[type=datetime-local], input[type=date], input[type=file], select, textarea {
  width: 100%; font: inherit; font-size: .95rem;
  padding: .58rem .75rem;
  background: var(--bean); color: var(--crema);
  border: 1.5px solid var(--line); border-radius: 10px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--honey); outline: none; box-shadow: 0 0 0 3px rgba(200,145,47,.22);
}
select option { background: var(--bean-2); color: var(--crema); }

/* a switch that reads as on/off at a glance */
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-size: .92rem; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 46px; height: 26px; border-radius: 999px; background: rgba(243,231,211,.16);
  position: relative; transition: background-color .16s ease; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--crema);
  transition: transform .16s ease;
}
.switch input:checked + .track { background: var(--leaf); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(200,145,47,.4); }
.switch input:disabled + .track { opacity: .4; }

/* --- notices ----------------------------------------------------------------- */
.notice {
  padding: .75rem 1rem; border-radius: 11px; margin-bottom: 1.1rem;
  border: 1.5px solid var(--line); font-size: .93rem; background: var(--bean-2);
}
.notice-ok    { border-color: rgba(78,138,85,.5);  background: rgba(78,138,85,.14); }
.notice-error { border-color: rgba(196,70,58,.5);  background: rgba(196,70,58,.14); }
.notice-info  { border-color: rgba(200,145,47,.5); background: rgba(200,145,47,.12); }

.empty-row { text-align: center; color: var(--muted); padding: 2.4rem 1rem; }

/* --- modal -------------------------------------------------------------------- */
dialog.sheet {
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--bean-2); color: var(--crema);
  padding: 0; width: min(660px, 94vw); max-height: 88vh;
}
dialog.sheet::backdrop { background: rgba(0,0,0,.62); }
dialog.sheet .sheet-head {
  padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem;
}
dialog.sheet .sheet-head h2 { margin: 0; }
dialog.sheet .sheet-body { padding: 1.3rem; overflow-y: auto; max-height: 62vh; }
dialog.sheet .sheet-foot {
  padding: 1rem 1.3rem; border-top: 1px solid var(--line);
  display: flex; gap: .6rem; justify-content: flex-end;
}
.sheet-close { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 1.5rem; cursor: pointer; line-height: 1; }

/* --- sign-in ------------------------------------------------------------------- */
.signin {
  min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem;
  background: radial-gradient(110% 80% at 50% 0%, #3B2417 0%, var(--bean) 60%, #150C08 100%);
}
.signin-card {
  width: min(420px, 100%); background: var(--bean-2);
  border: 1px solid var(--line); border-radius: 18px; padding: 2rem;
  text-align: center;
}
.signin-card img { width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 1.1rem; }
.signin-card form { text-align: left; margin-top: 1.4rem; }
.signin-card .btn { width: 100%; margin-top: .4rem; }
.signin-card .back { display: block; margin-top: 1.2rem; font-size: .87rem; color: var(--muted); }

/* --- print an order slip -------------------------------------------------------- */
@media print {
  .side, .page-head .actions, .btn, .topbar-mobile { display: none !important; }
  body { background: #fff; color: #000; }
  .admin { display: block; }
  .panel { border-color: #ccc; background: #fff; color: #000; }
  table.data th, table.data td { color: #000; }
}
