/* =========================================================
   VegBasket — shared styles (admin portal + restaurant app)
   ========================================================= */
:root {
  --green-900: #123f27;
  --green-800: #17573a;
  --green-700: #1f6f43;
  --green-100: #e3f0e7;
  --green-50:  #f1f7f2;
  --amber:     #e8a33d;
  --amber-100: #fbefd9;
  --red:       #c0392b;
  --red-100:   #fbe5e2;
  --blue:      #2d6cb5;
  --blue-100:  #e2edf9;
  --ink:       #1c2420;
  --muted:     #66706a;
  --line:      #e3e1d8;
  --bg:        #f7f5ef;
  --card:      #ffffff;
  --radius:    12px;
  --shadow:    0 1px 2px rgba(20,40,30,.06), 0 4px 16px rgba(20,40,30,.05);
  --font:      "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Sinhala", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.5;
}
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
small, .muted { color: var(--muted); }
.si { font-size: .85em; color: var(--muted); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=number], input[type=email],
input[type=tel], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-700); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 1rem; }
.row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--green-700); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important;
  background: var(--green-700); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--green-800); }
.btn-outline { background: #fff; color: var(--green-700); border-color: var(--line); }
.btn-outline:hover { background: var(--green-50); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #a03024; }
.btn-amber { background: var(--amber); color: #2b1d05; }
.btn-amber:hover { background: #d8922a; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Alerts / badges ---------- */
.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.alert-success { background: var(--green-100); color: var(--green-900); }
.alert-error   { background: var(--red-100); color: #7d2318; }
.alert-info    { background: var(--blue-100); color: #1d4a7e; }
.alert-warning { background: var(--amber-100); color: #6b4510; }

.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge-pending          { background: var(--amber-100); color: #7a4f0e; }
.badge-confirmed        { background: var(--blue-100);  color: #1d4a7e; }
.badge-out_for_delivery { background: #ece4fa; color: #4b2d86; }
.badge-delivered        { background: var(--green-100); color: var(--green-900); }
.badge-cancelled        { background: var(--red-100);   color: #7d2318; }
.badge-on  { background: var(--green-100); color: var(--green-900); }
.badge-off { background: #eee; color: #666; }

.up   { color: var(--red); font-weight: 700; }
.down { color: var(--green-700); font-weight: 700; }

/* ---------- Cards / tables ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cat-row td { background: var(--green-50); font-weight: 700; color: var(--green-800); font-size: .85rem; }

.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1.25rem; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.6rem; font-weight: 800; margin-top: .2rem; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.toolbar .field { margin: 0; }

/* =========================================================
   ADMIN PORTAL
   ========================================================= */
.admin { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--green-900); color: #dce9e0; padding: 1.25rem 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: .65rem; align-items: center; margin-bottom: 1.5rem; padding: 0 .4rem; }
.brand b { display: block; color: #fff; font-size: 1.1rem; }
.brand small { color: #9fc0aa; font-size: .72rem; }
.nav a { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; border-radius: 8px; color: #dce9e0; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: var(--green-700); color: #fff; }
.nav .count { margin-left: auto; background: var(--amber); color: #2b1d05; border-radius: 999px; font-size: .72rem; font-weight: 800; padding: 0 .45rem; }
.nav hr { border: 0; border-top: 1px solid rgba(255,255,255,.1); margin: .8rem 0; }
.main { padding: 1.75rem 2rem; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.topbar p { margin: 0; color: var(--muted); }
.menu-btn { display: none; }

input.price-input { width: 120px; text-align: right; }
.changed { background: var(--amber-100) !important; }

@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 250px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .main { padding: 1rem; }
  .menu-btn { display: inline-flex; }
}

/* =========================================================
   LOGIN SCREENS
   ========================================================= */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background:
  radial-gradient(circle at 15% 10%, var(--green-100), transparent 45%),
  radial-gradient(circle at 90% 90%, var(--amber-100), transparent 40%), var(--bg); }
.auth-box { width: 100%; max-width: 380px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { margin: .6rem 0 0; color: var(--green-800); font-size: 1.8rem; }
.auth-brand p { margin: 0; color: var(--muted); }

/* =========================================================
   RESTAURANT APP (mobile first)
   ========================================================= */
.app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: 150px; }
.app-header { position: sticky; top: 0; z-index: 20; background: var(--green-700); color: #fff; padding: .85rem 1rem; display: flex; align-items: center; gap: .7rem; }
.app-header .t { flex: 1; min-width: 0; }
.app-header b { display: block; font-size: 1.05rem; }
.app-header small { color: #cfe5d6; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header a { color: #fff; }
.app-body { padding: 1rem; }

.price-banner { background: var(--green-900); color: #e6f1ea; border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1rem; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.price-banner b { color: #fff; }

.search { position: sticky; top: 70px; z-index: 10; background: var(--bg); padding: .25rem 0 .75rem; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; margin-top: .6rem; scrollbar-width: none; }
.chip { white-space: nowrap; padding: .35rem .8rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink); }
.chip.active { background: var(--green-700); color: #fff; border-color: var(--green-700); }

.cat-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--green-800); font-weight: 800; margin: 1.1rem 0 .5rem; }
.item { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem .9rem; display: flex; align-items: center; gap: .75rem; margin-bottom: .55rem; }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 700; }
.item .price { font-weight: 800; color: var(--green-800); font-variant-numeric: tabular-nums; }
.item .price small { font-weight: 500; }
.item.in-cart { outline: 2px solid var(--green-700); }

.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.stepper button { width: 36px; height: 38px; border: 0; background: var(--green-50); color: var(--green-800); font-size: 1.2rem; font-weight: 700; cursor: pointer; }
.stepper input { width: 58px; border: 0; text-align: center; padding: 0; height: 38px; border-radius: 0; font-weight: 700; }
.stepper input:focus { outline: none; }

.cart-bar { position: fixed; left: 0; right: 0; bottom: 64px; z-index: 30; display: none; }
.cart-bar.show { display: block; }
.cart-bar .inner { max-width: 720px; margin: 0 auto; padding: 0 1rem; }
.cart-bar a { display: flex; justify-content: space-between; align-items: center; background: var(--amber); color: #2b1d05; padding: .85rem 1.1rem; border-radius: 14px; font-weight: 800; box-shadow: 0 6px 20px rgba(0,0,0,.18); text-decoration: none; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar .inner { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .55rem; font-size: .72rem; font-weight: 600; color: var(--muted); text-decoration: none; position: relative; }
.tabbar a.active { color: var(--green-700); }
.tabbar svg { width: 24px; height: 24px; }
.tabbar .dot { position: absolute; top: 4px; left: 55%; background: var(--amber); color: #2b1d05; font-size: .65rem; font-weight: 800; border-radius: 999px; padding: 0 .35rem; }

.order-card { display: block; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; margin-bottom: .6rem; color: var(--ink); text-decoration: none !important; }
.order-card .top { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.order-card .meta { color: var(--muted); font-size: .85rem; margin-top: .2rem; display: flex; justify-content: space-between; }

.timeline { display: flex; gap: 4px; margin: .75rem 0 .25rem; }
.timeline span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.timeline span.on { background: var(--green-700); }
.summary-line { display: flex; justify-content: space-between; padding: .3rem 0; }
.summary-line.total { font-weight: 800; font-size: 1.1rem; border-top: 1px solid var(--line); margin-top: .4rem; padding-top: .6rem; }

/* ---------- Landing ---------- */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: linear-gradient(160deg, var(--green-900), var(--green-700)); color: #fff; text-align: center; }
.landing h1 { font-size: 2.4rem; margin-top: 1rem; }
.landing p.tag { color: #cfe5d6; font-size: 1.1rem; margin-top: 0; }
.landing .choices { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); max-width: 620px; margin: 2rem auto 0; }
.landing .choice { background: #fff; color: var(--ink); border-radius: 16px; padding: 1.5rem; text-align: left; text-decoration: none !important; box-shadow: 0 8px 30px rgba(0,0,0,.2); transition: transform .15s; }
.landing .choice:hover { transform: translateY(-3px); }
.landing .choice b { display: block; font-size: 1.1rem; color: var(--green-800); margin-bottom: .25rem; }

@media print {
  .sidebar, .topbar .btn, .no-print, .menu-btn { display: none !important; }
  .admin { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; padding: 0; }
  body { background: #fff; }
}
