/* ============================================================
   base.css + components.css — EggspressIloilo
   Mobile-first, designed for Samsung A07 4G
   ============================================================ */

:root {
  --brand: #F5A623;
  --brand-dark: #C17D0D;
  --success: #3B6D11;
  --success-bg: #EAF3DE;
  --warning: #854F0B;
  --warning-bg: #FAEEDA;
  --danger: #A32D2D;
  --danger-bg: #FCEBEB;
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
  --topbar-height: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  background: #f5f5f0;
  color: #1a1a18;
  min-height: 100vh;
  overscroll-behavior: none;
}

@media (prefers-color-scheme: dark) {
  html, body { background: #1a1a18; color: #e8e6dc; }
}

/* ---- SCREENS ---- */
.screen { min-height: 100vh; }
#screen-app { padding-top: var(--topbar-height); padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }

/* ---- TOPBAR ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 0.5px solid rgba(0,0,0,0.1);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
@media (prefers-color-scheme: dark) {
  .topbar { background: #242420; border-bottom-color: rgba(255,255,255,0.08); }
}
.topbar-title { font-size: 17px; font-weight: 600; color: var(--brand-dark); }
.topbar-sub { font-size: 11px; color: #888; margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.gps-status { font-size: 11px; color: #888; }
.sync-status { font-size: 14px; }
.user-badge { font-size: 13px; font-weight: 500; background: var(--brand); color: #fff; padding: 4px 10px; border-radius: 20px; }

/* ---- APPROVAL BANNER ---- */
.approval-banner {
  background: var(--warning-bg); border-bottom: 0.5px solid #EF9F27;
  padding: 8px 16px; display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--warning);
}
.approval-banner button { background: var(--brand); color: #fff; border: none; border-radius: 6px; padding: 4px 12px; font-size: 12px; cursor: pointer; }

/* ---- PAGES ---- */
.page { padding: 12px 16px 16px; }
.page-header { font-size: 20px; font-weight: 600; margin-bottom: 16px; padding-top: 4px; }
.section-label { font-size: 11px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: 0.07em; margin: 16px 0 8px; }

/* ---- CARD ---- */
.card {
  background: #fff; border: 0.5px solid rgba(0,0,0,0.08); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) {
  .card { background: #2a2a26; border-color: rgba(255,255,255,0.08); }
}

/* ---- FORM ELEMENTS ---- */
.field-label { font-size: 13px; color: #666; margin-bottom: 6px; font-weight: 500; }
.field-hint { font-size: 11px; color: #aaa; font-weight: 400; }
@media (prefers-color-scheme: dark) { .field-label { color: #aaa; } }

select, input[type=number], input[type=text], input[type=tel], textarea {
  width: 100%; padding: 11px 14px; font-size: 16px;
  border: 0.5px solid rgba(0,0,0,0.15); border-radius: var(--radius-sm);
  background: #f9f9f6; color: #1a1a18;
  -webkit-appearance: none; appearance: none; margin-bottom: 4px;
  transition: border-color 0.15s;
}
@media (prefers-color-scheme: dark) {
  select, input[type=number], input[type=text], input[type=tel], textarea {
    background: #333330; border-color: rgba(255,255,255,0.12); color: #e8e6dc;
  }
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--brand);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }

/* ---- BUTTONS ---- */
.btn-primary {
  width: 100%; padding: 14px; background: var(--brand); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 16px; font-weight: 600;
  cursor: pointer; margin-top: 8px; transition: opacity 0.15s, transform 0.1s;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary {
  width: 100%; padding: 11px; background: none; color: #666;
  border: 0.5px solid rgba(0,0,0,0.15); border-radius: var(--radius-sm);
  font-size: 14px; cursor: pointer; margin-top: 8px;
}
.submit-note { font-size: 12px; color: #999; text-align: center; margin-top: 6px; }

/* ---- TOGGLE BUTTONS ---- */
.toggle-buttons { display: flex; gap: 0; border: 0.5px solid rgba(0,0,0,0.12); border-radius: var(--radius-sm); overflow: hidden; }
.btn-toggle { flex: 1; padding: 10px; border: none; background: none; font-size: 14px; cursor: pointer; color: #666; transition: all 0.15s; }
.btn-toggle.active { background: var(--brand); color: #fff; font-weight: 500; }

/* ---- SHIFT BUTTONS ---- */
.shift-buttons { display: flex; flex-direction: column; gap: 10px; }
.btn-shift { width: 100%; padding: 14px 16px; border: 0.5px solid rgba(0,0,0,0.12); border-radius: var(--radius-sm); background: #f9f9f6; text-align: left; cursor: pointer; transition: all 0.15s; }
.btn-shift.active { border-color: var(--brand); background: #fff8ec; }
.btn-shift:active { transform: scale(0.99); }
.shift-time { font-size: 12px; color: #888; }
.shift-name { font-size: 16px; font-weight: 500; margin-top: 2px; }

/* ---- LOADOUT ROWS ---- */
.loadout-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 0.5px solid rgba(0,0,0,0.06); }
.loadout-row:last-child { border-bottom: none; }
.loadout-size-name { font-size: 15px; font-weight: 500; }
.loadout-size-avail { font-size: 12px; color: #888; margin-top: 2px; }
.loadout-input { width: 80px; text-align: center; margin-bottom: 0; }

/* ---- PHOTOS ---- */
.photo-slot { padding: 12px 0; border-bottom: 0.5px solid rgba(0,0,0,0.06); }
.photo-slot:last-of-type { border-bottom: none; }
.photo-slot-label { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.photo-slot-prompt { font-size: 12px; color: #888; margin-bottom: 8px; }
.photo-preview { background: #f0ede6; border-radius: var(--radius-sm); min-height: 80px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; overflow: hidden; }
.photo-placeholder { font-size: 13px; color: #aaa; padding: 20px; text-align: center; }
.btn-capture {
  display: flex; align-items: center; gap: 6px; padding: 9px 16px;
  background: none; border: 0.5px solid rgba(0,0,0,0.15); border-radius: var(--radius-sm);
  font-size: 14px; cursor: pointer; color: #444;
}
.photo-status { font-size: 12px; margin-top: 4px; min-height: 16px; }
.required-badge { font-size: 11px; background: var(--danger-bg); color: var(--danger); padding: 2px 8px; border-radius: 8px; margin-left: 6px; font-weight: 600; }

/* Photo exception */
.photo-exception-section { margin-top: 12px; padding-top: 12px; border-top: 0.5px solid rgba(0,0,0,0.08); }
.btn-exception { background: none; border: none; font-size: 13px; color: #aaa; cursor: pointer; text-decoration: underline; padding: 4px 0; }
.exception-warning { background: var(--danger-bg); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; color: var(--danger); margin-bottom: 10px; line-height: 1.5; }
.exception-char-count { font-size: 12px; color: #aaa; margin-top: 4px; }
.btn-exception-submit { width: 100%; padding: 11px; background: var(--danger); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; margin-top: 8px; }
.btn-exception-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- PROCUREMENT LINES ---- */
.proc-line { display: grid; grid-template-columns: 1fr 70px 80px auto; gap: 8px; align-items: center; margin-bottom: 10px; }
.proc-line select, .proc-line input { margin-bottom: 0; }
.btn-remove-line { background: none; border: none; color: #aaa; font-size: 16px; cursor: pointer; padding: 8px 4px; }
.proc-total-line { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; color: #666; }
.proc-total-sum { font-size: 16px; font-weight: 600; padding-top: 10px; margin-top: 8px; border-top: 0.5px solid rgba(0,0,0,0.08); display: flex; justify-content: space-between; }

/* ---- SALE TOTAL ---- */
.sale-total { font-size: 20px; font-weight: 700; text-align: center; padding: 14px; background: var(--success-bg); border-radius: var(--radius-sm); color: var(--success); margin-top: 14px; }
.price-hint { font-size: 12px; color: #888; margin-top: 4px; min-height: 16px; }
.customer-row { display: flex; gap: 8px; align-items: center; }
.customer-row select { flex: 1; }
.btn-new-contact { white-space: nowrap; padding: 11px 12px; font-size: 13px; background: none; border: 0.5px solid rgba(0,0,0,0.15); border-radius: var(--radius-sm); cursor: pointer; color: #444; }

/* ---- RECONCILIATION ---- */
.reconciliation-preview { background: #f9f9f6; border-radius: var(--radius-sm); padding: 12px; margin-top: 14px; }
.recon-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.recon-ok .recon-variance span:last-child { color: var(--success); font-weight: 600; }
.recon-discrepancy .recon-variance span:last-child { color: var(--danger); font-weight: 600; }

/* ---- METRICS ---- */
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.metric-card { background: #f0ede6; border-radius: var(--radius-sm); padding: 14px; }
.metric-label { font-size: 12px; color: #888; margin-bottom: 5px; }
.metric-val { font-size: 22px; font-weight: 700; }

/* ---- SALES LOG ---- */
.log-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 0; border-bottom: 0.5px solid rgba(0,0,0,0.06); }
.log-item:last-child { border-bottom: none; }
.log-name { font-size: 14px; font-weight: 500; }
.log-detail { font-size: 12px; color: #888; margin-top: 2px; }
.log-flag { font-size: 11px; color: var(--danger); margin-top: 3px; }
.log-amount { font-size: 15px; font-weight: 600; text-align: right; }
.log-time { font-size: 11px; color: #aaa; text-align: right; margin-top: 2px; }

/* ---- APPROVALS ---- */
.approval-card { margin-bottom: 10px; }
.approval-header { display: flex; justify-content: space-between; align-items: flex-start; }
.approval-title { font-size: 15px; font-weight: 600; }
.approval-sub { font-size: 13px; color: #666; margin-top: 3px; }
.approval-thumb { border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.approval-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn-approve { flex: 1; padding: 10px; background: var(--success-bg); color: var(--success); border: 0.5px solid #a0c870; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-reject { flex: 1; padding: 10px; background: var(--danger-bg); color: var(--danger); border: 0.5px solid #f09595; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; }

/* ---- CONTACTS ---- */
.search-bar { padding: 8px 0 4px; }
.search-bar input { margin-bottom: 8px; }
.contact-card { margin-bottom: 8px; padding: 12px 14px; }
.contact-row { display: flex; align-items: center; gap: 12px; }
.contact-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; flex-shrink: 0; }
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-size: 14px; font-weight: 500; }
.contact-detail { font-size: 12px; color: #888; margin-top: 1px; }
.btn-whatsapp { color: #25D366; flex-shrink: 0; padding: 6px; }

/* ---- BOTTOM NAV ---- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 0.5px solid rgba(0,0,0,0.1);
  display: flex;
}
@media (prefers-color-scheme: dark) {
  .bottomnav { background: #242420; border-top-color: rgba(255,255,255,0.08); }
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; border: none; background: none;
  cursor: pointer; color: #aaa; font-size: 10px; padding: 8px 4px;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--brand-dark); }
.nav-btn svg { width: 22px; height: 22px; }

/* ---- MODAL ---- */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-content {
  position: relative; background: #fff; border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-height: 85vh; overflow-y: auto;
}
@media (prefers-color-scheme: dark) { .modal-content { background: #2a2a26; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; color: #aaa; cursor: pointer; }

/* ---- AUTH SCREEN ---- */
.auth-container { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; gap: 24px; }
.auth-logo { text-align: center; }
.auth-logo-icon { font-size: 64px; line-height: 1; }
.auth-logo-name { font-size: 28px; font-weight: 700; color: var(--brand-dark); margin-top: 8px; }
.auth-logo-sub { font-size: 14px; color: #888; margin-top: 4px; }
.auth-error { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 14px; width: 100%; text-align: center; }

/* ---- TOAST ---- */
.toast {
  position: fixed; bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%) translateY(10px);
  background: #333; color: #fff; padding: 10px 20px; border-radius: 20px;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; z-index: 300;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

/* ---- MISC ---- */
.empty-state { font-size: 14px; color: #aaa; text-align: center; padding: 24px 0; }
.loading { font-size: 14px; color: #aaa; text-align: center; padding: 24px 0; }
