/* Saflio POS — Base Foundation Styles v2 (Orange + Light Theme) */

/* ── CSS Custom Properties ── */
:root,
[data-theme='light'] {
  --surface-primary: #ffffff;
  --surface-secondary: #fafafa;
  --surface-tertiary: #f5f5f5;
  --surface-card: #ffffff;
  --surface-modal: #ffffff;
  --surface-input: #ffffff;
  --surface-hover: #f5f5f5;

  --text-primary: #171717;
  --text-secondary: #525252;
  --text-muted: #a3a3a3;
  --text-accent: #f97316;

  --border-color: #e5e5e5;
  --border-light: #f5f5f5;

  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-light: #fb923c;
  --accent-subtle: rgba(249, 115, 22, 0.08);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --bg-overlay: rgba(0, 0, 0, 0.3);

  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  --sidebar-width: 300px;
  --header-height: 48px;
}

[data-theme='dark'] {
  --surface-primary: #1a1a2e;
  --surface-secondary: #16213e;
  --surface-tertiary: #0f3460;
  --surface-card: #1e2a3a;
  --surface-modal: #1e2a45;
  --surface-input: #0d1b2a;
  --surface-hover: #2a3a5e;

  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6b7280;
  --text-accent: #f97316;

  --border-color: #2d3748;
  --border-light: #374151;

  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-light: #fb923c;
  --accent-subtle: rgba(249, 115, 22, 0.15);

  --bg-overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--surface-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── App Shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

.sidebar-shell-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-shell-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1em;
  font-weight: 700;
  color: var(--accent);
}

.brand-logo-placeholder { font-size: 1.3em; }

.sidebar-shell-mode-pill {
  font-size: 0.7em;
  color: var(--text-muted);
  background: var(--surface-tertiary);
  padding: 2px 8px;
  border-radius: 10px;
}

.sidebar-shell-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3em;
  cursor: pointer;
}

.sidebar-fit-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar-fit-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Profile card */
.sidebar-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface-tertiary);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.sidebar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1em;
  flex-shrink: 0;
}

.sidebar-profile-meta-compact {
  flex: 1;
  min-width: 0;
}

.sidebar-profile-inline-tight {
  display: flex;
  gap: 4px;
  font-size: 0.85em;
  line-height: 1.4;
}

.sidebar-profile-label { color: var(--text-muted); }
.sidebar-profile-name { color: var(--text-primary); font-weight: 600; }

/* Sync dock */
.sync-dock {
  padding: 8px 12px;
  background: var(--surface-tertiary);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.sync-status {
  font-size: 0.8em;
  color: var(--success);
  font-weight: 600;
}

.sync-time {
  font-size: 0.75em;
  color: var(--text-muted);
}

/* ── Navigation ── */
.sidebar-nav-section-heading {
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 12px 4px;
  font-weight: 600;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 4px;
}

.sidebar-nav-parent {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-size: 0.9em;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav-parent:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sidebar-nav-parent.active {
  background: var(--accent);
  color: white;
}

.sidebar-nav-icon {
  font-size: 1.1em;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sidebar-nav-title { font-weight: 600; }
.sidebar-nav-meta { font-size: 0.8em; color: inherit; opacity: 0.7; }

.sidebar-nav-parent.active .sidebar-nav-meta { opacity: 0.9; }

/* Bottom actions */
.sidebar-bottom-actions {
  margin-top: auto;
  padding: 8px 4px;
  border-top: 1px solid var(--border-color);
}

.sidebar-utility-card {
  padding: 12px;
  background: var(--surface-tertiary);
  border-radius: var(--radius);
}

.sidebar-utility-kicker {
  font-size: 0.75em;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.sidebar-utility-head-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.sidebar-utility-mini-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-direction: row;
}

.sidebar-mini-tool-button {
  background: var(--surface-hover);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  transition: background 0.15s;
}

.sidebar-mini-tool-button:hover {
  background: var(--surface-primary);
}

.logout-button {
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.15s;
  margin-top: 8px;
}

.logout-button:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* ── Content ── */
.content {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-primary);
}

.app-page-context {
  flex: 1;
}

.page-title {
  font-size: 1.3em;
  font-weight: 700;
}

/* ── Tab Panels ── */
.tab-panel {
  display: none;
  padding: 20px;
}

.tab-panel.active {
  display: block;
}

.tab-loading, .tab-empty, .tab-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 16px;
}

.tab-error {
  color: var(--danger);
}

/* ── Mobile Navigation ── */
.mobile-nav-toggle, .mobile-floating-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.3em;
  cursor: pointer;
  padding: 4px;
}

.mobile-app-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-secondary);
}

.mobile-app-header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-app-header-mark { font-size: 1.2em; }
.mobile-app-header-app { font-weight: 700; }
.mobile-app-header-page { color: var(--text-muted); font-size: 0.85em; }

.nav-shell-backdrop {
  display: none;
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.9em;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: auto;
  max-width: 360px;
}

.toast-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast-info { background: var(--info); color: white; }
.toast-success { background: var(--success); color: white; }
.toast-warning { background: var(--warning); color: #1a1a1a; }
.toast-error { background: var(--danger); color: white; }

/* ── Responsive ── */
/* ── Tablet responsive (768–1024px) ── */
@media (max-width: 1024px) {
  .sidebar {
    --sidebar-width: 240px;
  }
  
  .sidebar-profile-card-compact {
    padding: 8px;
    gap: 8px;
  }
  
  .sidebar-profile-meta-compact {
    font-size: 0.8em;
  }
  
  .sidebar-nav-parent {
    padding: 0.4rem 0.5rem;
    font-size: 0.82rem;
  }
  
  .sidebar-nav-section-heading {
    font-size: 0.7rem;
    padding: 0.35rem 0.5rem;
  }
  
  .content .tab-panel {
    padding: 12px;
  }
}

/* ── Mobile responsive (<768px) ── */
@media (max-width: 768px) {
  .sidebar {
    --sidebar-width: 280px;
    position: fixed;
    left: -100%;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-shell-close {
    display: block;
  }

  .nav-shell-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .nav-shell-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-nav-toggle, .mobile-floating-nav-toggle {
    display: block;
  }

  .mobile-floating-nav-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 50;
    background: var(--accent);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
    font-size: 1.3em;
  }

  .mobile-app-header {
    display: flex;
  }

  .page-header {
    padding: 8px 12px;
    display: none;
  }

  .tab-panel {
    padding: 12px;
  }
}

/* ── Auth Pages ── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--surface-primary);
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.auth-card {
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.auth-logo h1 { font-size: 1.5em; }

.auth-logo-icon { font-size: 2em; }

.auth-subtitle {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.9em;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form-message {
  padding: 8px 12px;
  background: var(--danger);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-field span {
  font-size: 0.85em;
  color: var(--text-secondary);
  font-weight: 500;
}

.auth-field input {
  padding: 10px 12px;
  background: var(--surface-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.95em;
}

.auth-field input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.auth-submit {
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-submit:hover { background: var(--accent-hover); }

.auth-footer {
  text-align: center;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.8em;
}

/* ── Marketing Page ── */
.marketing-hero {
  padding: 80px 20px;
  text-align: center;
  background: linear-gradient(135deg, var(--surface-secondary), var(--surface-tertiary));
}

.marketing-container {
  max-width: 960px;
  margin: 0 auto;
}

.marketing-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}

.marketing-logo-icon { font-size: 2em; }
.marketing-brand { font-size: 1.5em; font-weight: 700; color: var(--accent); }

.marketing-title {
  font-size: 2.5em;
  font-weight: 800;
  margin-bottom: 16px;
  line-height: 1.2;
}

.marketing-subtitle {
  font-size: 1.15em;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.marketing-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.marketing-button {
  padding: 12px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95em;
  transition: all 0.15s;
  display: inline-block;
}

.marketing-button-primary {
  background: var(--accent);
  color: white;
}

.marketing-button-primary:hover {
  background: var(--accent-hover);
  color: white;
}

.marketing-button-secondary {
  background: var(--surface-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.marketing-button-secondary:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.marketing-features {
  padding: 60px 20px;
}

.marketing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.marketing-feature-card {
  padding: 24px;
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

.feature-icon {
  font-size: 2em;
  display: block;
  margin-bottom: 12px;
}

.marketing-feature-card h3 {
  margin-bottom: 8px;
}

.marketing-feature-card p {
  color: var(--text-secondary);
  font-size: 0.9em;
}

.marketing-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.8em;
  border-top: 1px solid var(--border-color);
}

/* ── Common Elements ── */
input, select, textarea {
  font-family: var(--font);
  font-size: 0.9em;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--border-color);
  font-weight: 600;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9em;
}

tr:hover td {
  background: var(--surface-hover);
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── Modals ── */
.pos-modal-overlay[hidden],
.pos-receipt-overlay[hidden],
.scanner-overlay[hidden] {
  display: none !important;
}

.pos-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pos-modal {
  background: var(--surface-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 96%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.pos-modal-sm {
  max-width: 440px;
}

.pos-modal-wide {
  max-width: 1100px;
}

.pos-modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.pos-modal-footer {
  flex-shrink: 0;
}

.pos-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.pos-modal-header h3 {
  font-size: 1.1em;
}

.pos-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3em;
  cursor: pointer;
}

.pos-modal-close:hover {
  color: var(--text-primary);
}

.pos-modal-body {
  padding: 20px;
}

.pos-modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
}

/* ── Forms ── */
.pos-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pos-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pos-form-grid-narrow {
  grid-template-columns: 1fr 1fr;
}

.pos-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pos-field > span {
  font-size: 0.8em;
  color: var(--text-secondary);
  font-weight: 500;
}

.pos-field input, .pos-field select, .pos-field textarea {
  padding: 8px 10px;
  background: var(--surface-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.pos-field-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.pos-field-inline span {
  white-space: nowrap;
}

.pos-field-row {
  display: flex;
  gap: 4px;
}

.pos-field-row input {
  flex: 1;
}

/* ── Buttons ── */
.pos-btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pos-btn-primary {
  background: var(--accent);
  color: white;
}

.pos-btn-primary:hover { background: var(--accent-hover); }
.pos-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.pos-btn-secondary {
  background: var(--surface-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.pos-btn-secondary:hover { background: var(--surface-hover); }

.pos-btn-danger {
  background: var(--danger);
  color: white;
}

.pos-btn-danger:hover { background: #dc2626; }

.pos-btn-sm {
  padding: 4px 10px;
  font-size: 0.8em;
}

.pos-btn-icon {
  padding: 8px 10px;
  font-size: 1em;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8em;
  font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-muted { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  justify-content: center;
}

.pagination-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  background: var(--surface-card);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85em;
}

.pagination-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.pagination-info {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-left: 12px;
}

/* ── Row States ── */
.row-danger td { background: rgba(239, 68, 68, 0.05); }
.row-warning td { background: rgba(245, 158, 11, 0.05); }
.row-muted td { opacity: 0.6; }

/* ── Fatal Error ── */
.fatal-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 12px;
}
