/* ============================================================
   CAMP CANTEEN — DESIGN SYSTEM
   Two themes: dark (default) + light. Toggle via data-theme.
   ============================================================ */

/* ── DARK THEME ── */
:root {
  --bg:           #111110;
  --bg-raised:    #1c1c1a;
  --bg-overlay:   #242422;
  --bg-subtle:    #2c2c28;
  --border:       rgba(255,255,255,0.08);
  --border-strong:rgba(255,255,255,0.14);
  --text:         #EDEDEC;
  --text-2:       #9E9E9B;
  --text-3:       #57574F;
  --accent:       #E8A045;
  --accent-hover: #D4903A;
  --accent-dim:   rgba(232,160,69,0.12);
  --success:      #4AAA7A;
  --success-dim:  rgba(74,170,122,0.12);
  --danger:       #E5534B;
  --danger-dim:   rgba(229,83,75,0.12);
  --warning:      #D4A017;
  --warning-dim:  rgba(212,160,23,0.12);
  --info:         #4C8EDA;
  --info-dim:     rgba(76,142,218,0.12);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4);
  --shadow:       0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:    0 12px 40px rgba(0,0,0,0.6);
  --bg-2: var(--bg-raised);
  --bg-3: var(--bg-overlay);
  --bg-4: var(--bg-subtle);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 50px;
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --transition: 0.15s ease;
  --transition-md: 0.2s ease;
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
  --bg:           #F5F4F0;
  --bg-raised:    #FFFFFF;
  --bg-overlay:   #FFFFFF;
  --bg-subtle:    #EEEDE8;
  --border:       rgba(0,0,0,0.09);
  --border-strong:rgba(0,0,0,0.15);
  --text:         #1C1C1A;
  --text-2:       #6F6E66;
  --text-3:       #AEACA3;
  --accent:       #BF7A28;
  --accent-hover: #A66820;
  --accent-dim:   rgba(191,122,40,0.1);
  --success:      #2D7A57;
  --success-dim:  rgba(45,122,87,0.1);
  --danger:       #C9312C;
  --danger-dim:   rgba(201,49,44,0.1);
  --warning:      #A07010;
  --warning-dim:  rgba(160,112,16,0.1);
  --info:         #2E6DB0;
  --info-dim:     rgba(46,109,176,0.1);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08),0 1px 2px rgba(0,0,0,0.05);
  --shadow:       0 4px 16px rgba(0,0,0,0.1),0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg:    0 12px 40px rgba(0,0,0,0.13),0 4px 12px rgba(0,0,0,0.08);
  --bg-2: var(--bg-raised);
  --bg-3: var(--bg-overlay);
  --bg-4: var(--bg-subtle);
}

/* ── RESET ── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* ── THEME TRANSITION ── */
body.theme-transitioning,body.theme-transitioning * {
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease !important;
}

/* ── THEME TOGGLE ── */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--text-2);
  cursor: pointer; font-size: 15px;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-subtle); color: var(--text); }

/* Show moon in dark mode, sun in light mode */
.icon-moon { display: block; }
.icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: block; }

/* POS theme button hover */
.pos-theme-btn:hover { background: var(--bg-subtle) !important; color: var(--text) !important; }

/* ── LOGIN ── */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}

.login-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 48px 32px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 12px; line-height: 1; }
.login-card h1 { text-align: center; font-size: 1.75rem; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.02em; }
.login-subtitle { text-align: center; color: var(--text-2); margin-bottom: 32px; font-size: 0.875rem; }
.login-error {
  color: var(--danger); font-size: 0.875rem; text-align: center;
  padding: 8px 12px; background: var(--danger-dim);
  border-radius: var(--radius-sm); margin-top: 12px;
}
/* Login button matches input field radius exactly */
.login-card .btn-lg { border-radius: var(--radius-sm); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm); border: none;
  font-family: var(--font); font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  text-decoration: none; white-space: nowrap; user-select: none; -webkit-user-select: none;
  letter-spacing: -0.01em;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; font-weight: 600; }
.btn-success:hover:not(:disabled) { filter: brightness(0.9); }
.btn-danger  { background: var(--danger);  color: #fff; font-weight: 600; }
.btn-danger:hover:not(:disabled)  { filter: brightness(0.9); }
.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.5rem; font-size: 1rem; font-weight: 600; }

/* ── INPUTS ── */
.input-field {
  width: 100%; background: var(--bg-overlay);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font); font-size: 0.875rem;
  padding: 0.6rem 0.875rem;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  outline: none; appearance: none; -webkit-appearance: none;
  box-shadow: var(--shadow-sm);
}
.input-field:focus { border-color: var(--accent); background: var(--bg-raised); box-shadow: var(--shadow); }
.input-field::placeholder { color: var(--text-3); }
.input-field option { background: var(--bg-overlay); }

/* ── FORM ── */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.form-group label { font-size: 0.75rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.5rem; border-radius: var(--radius-pill);
  font-size: 0.72rem; font-weight: 600; white-space: nowrap;
}
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-danger  { background: var(--danger-dim);  color: var(--danger);  }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-info    { background: var(--info-dim);    color: var(--info);    }
.badge-neutral { background: var(--bg-subtle);   color: var(--text-2);  }
.badge-accent  { background: var(--accent-dim);  color: var(--accent);  }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: overlay-in 0.15s ease;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-content.modal-sm { max-width: 420px; }
.modal-content.modal-lg { max-width: 900px; }
.modal-content.modal-xl { max-width: 1100px; }

.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.modal-close {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 1rem; padding: 4px; border-radius: var(--radius-sm); line-height: 1;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0; margin-left: 12px;
}
.modal-close:hover { color: var(--text); background: var(--bg-subtle); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 24px; border-top: 1px solid var(--border);
}

/* ── TOASTS ── */
.toast-container {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 2000; align-items: center;
}
.toast {
  padding: 0.55rem 1.2rem; border-radius: var(--radius-pill); font-size: 0.78rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3); min-width: unset; max-width: 360px; width: auto;
  animation: toast-in 0.2s var(--ease); text-align: center;
}
.toast-info    { background: #1e2235; border: 1px solid var(--border-strong); color: #fff; }
.toast-success { background: #166534; border: none; color: #fff; }
.toast-error   { background: #991b1b; border: none; color: #fff; }
.toast-warning { background: #92400e; border: none; color: #fff; }
.toast-fade-out { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(8px); } }

/* ── UTILITIES ── */
.hidden { display: none !important; }
.text-muted { color: var(--text-2); font-size: 0.875rem; }
code { font-family: 'SF Mono','Fira Code',monospace; background: var(--bg-subtle); padding: 0.1em 0.4em; border-radius: var(--radius-sm); font-size: 0.82em; }

/* ── SCROLLBARS ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── TABLES ── */
.table-wrap {
  overflow-x: auto; overflow-y: visible;
  border-radius: var(--radius); border: 1px solid var(--border);
  max-width: 100%; background: var(--bg-raised);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  padding: 0.65rem 1rem; text-align: left;
  font-size: 0.7rem; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.07em;
  background: var(--bg-raised); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-subtle); }
.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--text-3); font-size: 0.875rem; }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px 0; font-size: 0.875rem; color: var(--text-2); }

/* ── LOW STOCK BANNER ── */
.low-stock-banner { background: var(--warning-dim); border: 1px solid var(--warning); border-radius: var(--radius); padding: 10px 16px; color: var(--warning); font-size: 0.875rem; font-weight: 500; margin-bottom: 16px; }

/* ── MOBILE ── */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-content { max-width: 100%; width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; display: flex; flex-direction: column; }
  .modal-content.modal-sm,.modal-content.modal-lg { max-width: 100%; }
  .modal-header { padding: 16px; flex-shrink: 0; }
  .modal-body   { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
  .modal-footer .btn { flex: 1; min-width: 120px; justify-content: center; }
  .toast-container { top: 14px; bottom: auto; right: auto; left: 50%; transform: translateX(-50%); padding: 0; align-items: center; }
  .toast { min-width: unset; max-width: 88vw; width: auto; text-align: center; }
  /* Touch-friendly tap targets */
  .btn    { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .btn-lg { min-height: 52px; }
  .input-field { min-height: 44px; font-size: 16px; } /* 16px prevents iOS auto-zoom */
  .data-table th,.data-table td { padding: 0.6rem 0.75rem; font-size: 0.78rem; }
  /* Make tables scroll smoothly */
  .table-wrap { -webkit-overflow-scrolling: touch; }
}

/* ===== OFFLINE BANNER ===== */
#offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: var(--warning); color: #000;
  text-align: center; font-size: 0.85rem; font-weight: 600;
  padding: 8px 16px;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  pointer-events: none;
}
#offline-banner.visible { transform: translateY(0); }

/* Session expired banner — shown inside login card on graceful expiry */
.session-expired-banner {
  background: rgba(239,68,68,0.1);
  border: 1.5px solid rgba(239,68,68,0.3);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 16px;
  animation: banner-in 0.3s ease;
}
@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── CUSTOM SELECT DROPDOWN ── */
.cs-wrap {
  position: relative;
  display: inline-block;
}
.cs-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  box-sizing: border-box;
}
.cs-trigger:hover { background: var(--bg-overlay); color: var(--text); border-color: var(--border-strong); }
.cs-trigger.open  { background: var(--bg-overlay); color: var(--text); border-color: var(--border-strong); }
.cs-arrow {
  font-size: 0.55rem;
  color: var(--text-3);
  transition: transform 0.15s ease;
  line-height: 1;
  flex-shrink: 0;
}
.cs-trigger.open .cs-arrow { transform: rotate(180deg); }
.cs-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 100%;
  background: var(--bg-overlay);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 9999;
  overflow: hidden;
  animation: cs-in 0.1s ease;
}
@keyframes cs-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-3px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.cs-option {
  padding: 7px 14px;
  font-size: 0.8rem;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.cs-option:hover    { background: var(--bg-subtle); color: var(--text); }
.cs-option.selected { color: var(--accent); font-weight: 600; }

/* ── Theme toggle icon colour ──────────────────────────────────────────────── */
#icon-moon, #icon-sun { color: #60a5fa; }
