/* ============================================================
   Camping Pack-Planer — slick, mobile-first stylesheet
   ============================================================ */
:root {
  --green:        #2f8f5b;
  --green-dark:   #246e47;
  --green-soft:   #e7f4ec;
  --car:          #2f6fb0;
  --car-soft:     #e7eff7;
  --ww:           #2f8f5b;
  --ww-soft:      #e7f4ec;
  --amber:        #e08e0b;
  --danger:       #d6453d;
  --danger-soft:  #fdecea;
  --ink:          #1f2a30;
  --muted:        #6b7a82;
  --line:         #e6ebee;
  --bg:           #f3f6f7;
  --card:         #ffffff;
  --hover:        #eef2f3;
  --shadow:       0 6px 24px rgba(20, 40, 30, 0.08);
  --shadow-sm:    0 2px 8px rgba(20, 40, 30, 0.06);
  --radius:       16px;
  --radius-sm:    10px;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
button { font-family: inherit; cursor: pointer; }
input, select, button { font-size: 16px; } /* prevent iOS zoom */
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: var(--radius-sm);
  padding: 11px 16px; font-weight: 600; color: #fff;
  background: var(--green); transition: background-color .15s, transform .05s, box-shadow .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
/* Darken (not brighten) on hover so white text keeps its contrast. */
.btn:hover { background: var(--green-dark); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-secondary { background: #5a6b73; }
.btn-secondary:hover { background: #46535a; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b8352e; color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 14px; border-radius: 8px; }
.icon-btn {
  border: none; background: transparent; color: var(--muted);
  width: 34px; height: 34px; border-radius: 8px; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }

/* ---------- Inputs ---------- */
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; color: var(--ink);
  transition: border-color .15s;
}
input:focus, select:focus { outline: none; border-color: var(--green); }
label.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field-row { margin-bottom: 12px; }

/* ============================================================
   Login
   ============================================================ */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #2f8f5b 0%, #246e47 55%, #1c5238 100%);
}
.login-card {
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  width: 100%; max-width: 380px; padding: 32px 26px;
}
.login-logo { text-align: center; font-size: 42px; margin-bottom: 6px; }
.login-card h1 { text-align: center; font-size: 1.35rem; margin: 0 0 2px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: .9rem; margin: 0 0 22px; }
.login-error {
  background: var(--danger-soft); color: var(--danger); border-radius: 10px;
  padding: 10px 12px; font-size: .88rem; margin-bottom: 14px;
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff; padding: 10px 14px; box-shadow: var(--shadow-sm);
}
.topbar-inner { max-width: 920px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }
.brand .logo { font-size: 1.3rem; }
.topbar-spacer { flex: 1; }
.topbar .icon-btn { color: #fff; }
.topbar .icon-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.lang-toggle { display: flex; background: rgba(255,255,255,.18); border-radius: 8px; overflow: hidden; }
.lang-toggle button {
  border: none; background: transparent; color: rgba(255,255,255,.78);
  padding: 6px 11px; font-weight: 700; font-size: 13px;
  transition: background-color .15s, color .15s;
}
.lang-toggle button:hover { background: rgba(255,255,255,.18); color: #fff; }
.lang-toggle button.active,
.lang-toggle button.active:hover { background: #fff; color: var(--green-dark); }

/* Light-background variant (used inside the white login card) */
.lang-toggle--light { background: #e6ecef; }
.lang-toggle--light button { color: #56646b; }
.lang-toggle--light button:hover { background: #d6dee2; color: var(--ink); }
.lang-toggle--light button.active,
.lang-toggle--light button.active:hover { background: var(--green); color: #fff; }

/* ============================================================
   Layout
   ============================================================ */
.container { max-width: 920px; margin: 0 auto; padding: 14px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-head .spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* List selector bar */
.listbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.listbar select { flex: 1; min-width: 160px; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; background: var(--green-soft); color: var(--green-dark);
}
.badge.readonly { background: #eef2f3; color: var(--muted); }

/* Empty state */
.empty-state { text-align: center; padding: 40px 16px; }
.empty-state .big { font-size: 44px; margin-bottom: 8px; }

/* ============================================================
   Vehicle config (collapsible)
   ============================================================ */
.collapsible > .collapse-body { display: none; }
.collapsible.open > .collapse-body { display: block; }
.collapse-head { cursor: pointer; user-select: none; }
.collapse-head .chev { transition: transform .2s; margin-left: auto; }
.collapsible.open .collapse-head .chev { transform: rotate(180deg); }

.veh-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.veh-box { border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.veh-box.car { border-color: #cfe0f1; }
.veh-box.ww  { border-color: #cfe8d9; }
.veh-box h3 { margin: 0 0 10px; font-size: .98rem; display: flex; align-items: center; gap: 7px; }
.veh-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nose-box { background: #faf6ec; border: 1.5px solid #f0e4c4; border-radius: var(--radius-sm); padding: 12px; margin-top: 4px; }
.nose-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nose-note { font-size: .8rem; color: #8a6d2a; margin-top: 8px; }
.reserve-box { background: #eef4f7; border: 1.5px solid #d6e2e9; border-radius: var(--radius-sm); padding: 12px; margin-top: 10px; }
.reserve-box .nose-note { color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); font-weight: 600; }

/* ============================================================
   Summary cards
   ============================================================ */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.sum-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 14px; border-top: 4px solid var(--line); position: relative; overflow: hidden;
}
.sum-card.car  { border-top-color: var(--car); }
.sum-card.ww   { border-top-color: var(--ww); }
.sum-card.over { border-top-color: var(--danger); background: var(--danger-soft); }
.sum-card.reserve { border-top-color: var(--amber); background: #fdf6e6; }
.sum-card.reserve .sum-main { color: #a36c08; }
.sum-card.reserve .sum-bar > span { background: var(--amber); }
.sum-title { font-size: .82rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: center; gap: 6px; }
.sum-main { font-size: 1.6rem; font-weight: 800; margin: 6px 0 0; }
.sum-main .of { font-size: .95rem; font-weight: 600; color: var(--muted); }
.sum-card.over .sum-main { color: var(--danger); }
.sum-bar { height: 7px; background: #eef2f3; border-radius: 999px; margin: 10px 0 8px; overflow: hidden; }
.sum-bar > span { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .3s; }
.sum-card.over .sum-bar > span { background: var(--danger); }
.sum-meta { font-size: .78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.sum-remain { font-size: .82rem; font-weight: 700; margin-top: 2px; }
.sum-remain.ok { color: var(--green); }
.sum-remain.over { color: var(--danger); }
.sum-remain.reserve { color: #a36c08; }
.sum-card.over .sum-remain.ok { color: var(--green); }
.sum-loaded { font-size: .82rem; font-weight: 600; margin-top: 2px; }

.alert {
  display: flex; align-items: center; gap: 8px; background: var(--danger-soft);
  color: var(--danger); border-radius: var(--radius-sm); padding: 11px 13px;
  font-weight: 600; font-size: .9rem; margin-bottom: 12px;
  animation: shake .45s;
}
.alert.reserve { background: #fdf3df; color: #9a6a08; animation: none; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ============================================================
   Toolbar (filter / sort / checklist)
   ============================================================ */
.search-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 4px 10px; background: #fff; }
.search-bar:focus-within { border-color: var(--green); }
.search-bar .search-ico { color: var(--muted); font-size: 15px; }
.search-bar input { border: none; padding: 7px 0; flex: 1; background: transparent; }
.search-bar input:focus { outline: none; }
.search-bar .icon-btn { width: 28px; height: 28px; font-size: 14px; }
/* Hide the clear button while the field is empty (placeholder visible). */
.search-bar input:placeholder-shown ~ .search-clear { display: none; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); background: #fff; color: var(--muted);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.toolbar .grow { flex: 1; }
.sort-wrap { display: flex; align-items: center; gap: 6px; }
.sort-wrap select { width: auto; padding: 8px 10px; }
.switch-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
  border-radius: 999px; border: 1.5px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted);
}
.switch-pill.active { background: var(--amber); border-color: var(--amber); color: #fff; }

/* Toggle switch */
.toggle { position: relative; width: 42px; height: 24px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track { position: absolute; inset: 0; background: #cfd8dc; border-radius: 999px; transition: .2s; }
.toggle .track::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle input:checked + .track { background: var(--green); }
.toggle input:checked + .track::before { transform: translateX(18px); }

/* ============================================================
   Items list
   ============================================================ */
.items { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; flex-direction: column; gap: 8px;
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
}
.item-top { display: flex; align-items: center; gap: 10px; }
.item.is-loaded { background: var(--green-soft); border-color: #cfe8d9; }
.item .check { flex: none; }
.item-check {
  width: 26px; height: 26px; border-radius: 7px; border: 2px solid #c4ced3; background: #fff;
  display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 16px;
}
.item-check.on { background: var(--green); border-color: var(--green); }
.item-main { min-width: 0; }
.item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: .78rem; color: var(--muted); }
.item-right { display: flex; align-items: center; gap: 10px; }
.item-total { font-weight: 800; min-width: 56px; text-align: right; }

.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 30px; height: 30px; border: none; border-radius: 8px; background: #eef2f3; font-weight: 800; font-size: 16px; color: var(--ink); }
.qty button:active { background: #e0e6e8; }
.qty .v { min-width: 22px; text-align: center; font-weight: 700; }

.loc-group { display: inline-flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.loc-group button { border: none; background: #fff; color: var(--muted); padding: 7px 9px; font-size: 12px; font-weight: 700; min-width: 36px; }
.loc-group button.active.ww { background: var(--ww); color: #fff; }
.loc-group button.active.auto { background: var(--car); color: #fff; }
.loc-group button.active.none { background: #95a5a6; color: #fff; }

.item-row-2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }

/* Add form */
.add-form { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; margin-top: 12px; }

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 25, 20, .5); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
.modal {
  background: #fff; width: 100%; max-width: 460px; border-radius: 20px 20px 0 0;
  padding: 20px; max-height: 90dvh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 4px; font-size: 1.15rem; }
.modal .intro { color: var(--muted); font-size: .88rem; margin: 0 0 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.user-row, .share-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.user-row .name { flex: 1; font-weight: 600; }
.list-divider { height: 1px; background: var(--line); margin: 16px 0; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: .88rem; font-weight: 600; z-index: 80; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.save-pill { font-size: 12px; color: rgba(255,255,255,.85); display: inline-flex; align-items: center; gap: 5px; }

/* ============================================================
   Responsive — tablet/desktop
   ============================================================ */
@media (min-width: 720px) {
  .veh-grid { grid-template-columns: 1fr 1fr; }
  .modal { border-radius: 20px; align-self: center; }
  .modal-backdrop { align-items: center; padding: 20px; }
}
@media (max-width: 420px) {
  .add-form { grid-template-columns: 1fr 1fr; }
  .add-form .btn { grid-column: 1 / -1; }
  .summary { grid-template-columns: 1fr; }
}

/* ============================================================
   Dark mode
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8edef; --muted: #9aa7ad; --line: #2c3a40;
    --bg: #131a1d; --card: #1b2429; --green-soft: #1d3326; --car-soft: #16293b;
    --hover: #2a3a41;
    --shadow: 0 6px 24px rgba(0,0,0,.4); --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
  }
  .qty button:active { background: #2f4047; }
  .toggle .track { background: #3a4a52; }
  .toggle .track::before { background: #c6d0d4; }
  input[type=text], input[type=password], input[type=number], select { background: #131a1d; color: var(--ink); }
  .chip, .item, .veh-box, .loc-group, .search-bar { background: #131a1d; }
  .loc-group button { background: #131a1d; }
  .qty button { background: #243036; color: var(--ink); }
  .btn-ghost { color: var(--ink); }
  .nose-box { background: #2a2616; border-color: #4a4322; }
  .nose-note { color: #cbb56a; }
  .reserve-box { background: #1d272b; border-color: #2c3a40; }
  .reserve-box .nose-note { color: var(--muted); }
  .sum-card.reserve { background: #2a2616; }
  .sum-card.reserve .sum-main, .sum-remain.reserve { color: #e0b14c; }
  .alert.reserve { background: #2c2613; color: #e0b14c; }
  .modal, .login-card { background: #1b2429; }
  .item-check { background: #131a1d; }
  .lang-toggle--light { background: #243036; }
  .lang-toggle--light button { color: var(--muted); }
  .lang-toggle--light button:hover { background: #2c3a40; color: var(--ink); }
}
