/* ============================================
   UNIVERSAL CSS - Gwala-Connect Design System
   ILLITERATE-FIRST DESIGN
   For users who cannot read properly
   Works under extreme time pressure
   MINI SIDEBAR + FULL SIDEBAR
   SMART HEADER (doesn't duplicate)
   ============================================ */

:root {
  /* Colors - HIGH CONTRAST for illiterate users */
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --blue: #2563eb;
  --blue2: #1d4ed8;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --yellow: #f59e0b;
  --yellow-light: #fef3c7;
  --shadow: 0 12px 26px rgba(0, 0, 0, 0.08);

  /* Color Meanings (DO NOT CHANGE) */
  /* Green = Success/Accepted */
  /* Red = Rejected/Error */
  /* Yellow = Hold/Warning */
  /* Blue = Info/Action */

  /* Spacing - Mobile First */
  --header-height: 64px;
  --status-height: 56px;
  --bottom-height: 80px;
  --gap: 8px;
  --padding: 8px;

  /* Border Radius - Large for easy touch */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  /* Icon Sizes - BIG for illiterate users */
  --icon-sm: 24px;
  --icon-md: 32px;
  --icon-lg: 48px;
  --icon-xl: 64px;
  
  /* Sidebar widths */
  --mini-sidebar-width: 70px;
  --full-sidebar-width: 280px;
}

/* Reset & Base */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

/* Main content padding for sidebar */
main {
  padding-left: 0;
  transition: padding-left 0.3s ease;
}

/* ============================================
   MINI SIDEBAR (Always Visible)
   ============================================ */
.mini-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--mini-sidebar-width);
  background: #fff;
  border-right: 2px solid var(--line);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 12px;
}

/* Push main content when sidebar open */
body.sidebar-open main {
  padding-left: var(--mini-sidebar-width);
}

.mini-sidebar-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
}

.mini-sidebar-item {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-lg);
  background: #f8fafc;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.mini-sidebar-item:hover {
  background: var(--blue);
  border-color: var(--blue);
  transform: scale(1.05);
}

.mini-sidebar-item:hover .mini-sidebar-icon {
  color: #fff;
}

.mini-sidebar-icon {
  font-size: var(--icon-md);
  color: var(--text);
  transition: color 0.2s;
}

/* ============================================
   FULL SIDEBAR (Hidden by Default)
   ============================================ */
.full-sidebar {
  position: fixed;
  left: -280px;
  top: 0;
  bottom: 0;
  width: var(--full-sidebar-width);
  background: #fff;
  border-right: 2px solid var(--line);
  z-index: 9999;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.1);
}

.full-sidebar.open {
  left: 0;
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9998;
  display: none;
}

.sidebar-overlay.open {
  display: block;
}

.full-sidebar-header {
  padding: 20px;
  border-bottom: 2px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.full-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  font-size: 18px;
  color: var(--blue);
}

.sidebar-close-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.2s;
}

.sidebar-close-btn:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.full-sidebar-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.full-sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: #0f172a !important;
  transition: all 0.2s;
  cursor: pointer;
}

.full-sidebar-item:hover {
  background: var(--blue);
  color: #fff !important;
  transform: translateX(4px);
}

.full-sidebar-icon {
  font-size: var(--icon-md);
  flex-shrink: 0;
}

.full-sidebar-text {
  flex: 1;
  min-width: 0;
}

.full-sidebar-title {
  font-weight: 900;
  font-size: 14px;
  color: #0f172a !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.full-sidebar-item:hover .full-sidebar-title {
  color: #fff !important;
}

.full-sidebar-subtitle {
  font-size: 11px;
  color: #64748b !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.full-sidebar-item:hover .full-sidebar-subtitle {
  color: #fff !important;
}

.full-sidebar-footer {
  padding: 16px;
  border-top: 2px solid var(--line);
  flex-shrink: 0;
}

.lang-toggle-btn {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--line);
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  font-size: 14px;
  transition: all 0.2s;
}

.lang-toggle-btn:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* App Layout - With Status Bar */
.app {
  height: 100%;
  display: grid;
  grid-template-rows: var(--header-height) 1fr var(--bottom-height) var(--status-height);
  gap: var(--gap);
  padding: var(--padding);
}

/* ============================================
   UNIVERSAL NAVBAR (TOP)
   ============================================ */
.navbar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.navbar-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #e0f2fe, #dbeafe);
  border: 1px solid #c7d2fe;
  font-size: var(--icon-md);
  flex-shrink: 0;
}

.navbar-title {
  font-weight: 800;
  font-size: 15px;
  color: #0f172a;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.navbar-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--icon-md);
  transition: all 0.2s;
}

.navbar-btn:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
}

.navbar-btn.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* Drawer Menu */
.navbar-drawer {
  position: fixed;
  top: 0;
  left: -300px;
  width: 300px;
  height: 100vh;
  background: #fff;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  z-index: 1000;
  transition: left 0.3s ease;
  overflow-y: auto;
}

.navbar-drawer.open {
  left: 0;
}

.navbar-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 999;
  display: none;
}

.navbar-drawer-overlay.open {
  display: block;
}

.navbar-drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-drawer-menu {
  padding: 8px;
}

.navbar-drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  color: var(--text);
}

.navbar-drawer-item:hover {
  background: #f1f5f9;
}

.navbar-drawer-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--icon-md);
  background: #eff6ff;
  color: var(--blue);
}

/* ============================================
   UNIVERSAL STATUS BAR (BOTTOM)
   ============================================ */
.status-bar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--status-height);
  z-index: 100;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 8px;
}

.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  transition: background 0.2s;
  min-width: 60px;
}

.status-item:hover {
  background: #f1f5f9;
}

.status-item-icon {
  font-size: var(--icon-md);
  line-height: 1;
}

.status-item-value {
  font-weight: 900;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
}

.status-item-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.status-item.green .status-item-value {
  color: var(--green);
}

.status-item.red .status-item-value {
  color: var(--red);
}

.status-item.yellow .status-item-value {
  color: var(--yellow);
}

.status-item.blue .status-item-value {
  color: var(--blue);
}

/* Status Panel Overlay */
.status-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  max-height: 70vh;
  overflow-y: auto;
}

.status-panel.open {
  transform: translateY(0);
}

.status-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 999;
  display: none;
}

.status-panel-overlay.open {
  display: block;
}

.status-panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: #fff;
}

.status-panel-content {
  padding: 16px;
}

/* ============================================
   PANIC BUTTONS (BOTTOM BAR)
   ============================================ */
.panic-bar {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 10px;
  height: var(--bottom-height);
}

.panic-btn {
  border: none;
  border-radius: var(--radius-2xl);
  font-weight: 1200;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  position: relative;
}

.panic-btn:active {
  transform: scale(0.98);
}

.panic-btn-icon {
  font-size: var(--icon-lg);
  margin-bottom: 4px;
}

.panic-btn-label {
  font-size: 14px;
  font-weight: 900;
}

.panic-btn-hold {
  background: var(--yellow);
  color: #fff;
}

.panic-btn-save {
  background: var(--green);
  color: #fff;
  font-size: 18px;
}

.panic-btn-undo {
  background: var(--red);
  color: #fff;
}

/* ============================================
   ILLITERATE-FIRST COMPONENTS
   ============================================ */

/* Big Icon Buttons - NO TEXT REQUIRED */
.icon-btn {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  border: none;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--icon-lg);
  box-shadow: var(--shadow);
  transition: all 0.2s;
  min-width: 64px;
  min-height: 64px;
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Color-Coded Buttons (NO TEXT) */
.icon-btn.green {
  background: var(--green);
  color: #fff;
}

.icon-btn.red {
  background: var(--red);
  color: #fff;
}

.icon-btn.yellow {
  background: var(--yellow);
  color: #fff;
}

.icon-btn.blue {
  background: var(--blue);
  color: #fff;
}

/* Status Badges - COLOR MEANING */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  font-weight: 900;
  font-size: 14px;
  min-width: 100px;
  justify-content: center;
}

.status-badge.green {
  background: var(--green-light);
  color: var(--green);
}

.status-badge.red {
  background: var(--red-light);
  color: var(--red);
}

.status-badge.yellow {
  background: var(--yellow-light);
  color: var(--yellow);
}

.status-badge.blue {
  background: #eff6ff;
  color: var(--blue);
}

/* Big Number Display - FOR ILLITERATE USERS */
.big-number {
  font-size: 48px;
  font-weight: 1200;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
}

.big-number.small {
  font-size: 32px;
}

.big-number.large {
  font-size: 64px;
}

/* Color-Coded Number */
.big-number.green {
  color: var(--green);
}

.big-number.red {
  color: var(--red);
}

.big-number.yellow {
  color: var(--yellow);
}

/* Visual Balance Display - ALWAYS VISIBLE */
.balance-display {
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  color: #fff;
  padding: 16px;
  border-radius: var(--radius-2xl);
  text-align: center;
  margin: 8px;
}

.balance-display.green {
  background: linear-gradient(135deg, var(--green), #15803d);
}

.balance-display.red {
  background: linear-gradient(135deg, var(--red), #b91c1c);
}

/* Visual Progress - NO TEXT */
.progress-bar {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.3s;
  position: relative;
}

/* Error State - VISUAL NOT TEXT */
.error-shake {
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* Success Flash - VISUAL FEEDBACK */
.success-flash {
  animation: flash-green 0.5s;
}

@keyframes flash-green {
  0%, 100% { background: transparent; }
  50% { background: var(--green-light); }
}

/* Error Flash - VISUAL FEEDBACK */
.error-flash {
  animation: flash-red 0.5s;
}

@keyframes flash-red {
  0%, 100% { background: transparent; }
  50% { background: var(--red-light); }
}

/* WhatsApp Receipt Lock - VISUAL */
.whatsapp-locked {
  position: fixed;
  bottom: calc(var(--status-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: #25D366;
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  font-weight: 900;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

/* Visual Card - ICON + COLOR */
.visual-card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 80px;
}

.visual-card:active {
  transform: scale(0.98);
}

.visual-card.selected {
  border-color: var(--blue);
  background: #eff6ff;
}

.visual-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--icon-md);
  flex-shrink: 0;
}

.visual-card-icon.green {
  background: var(--green-light);
  color: var(--green);
}

.visual-card-icon.red {
  background: var(--red-light);
  color: var(--red);
}

.visual-card-icon.yellow {
  background: var(--yellow-light);
  color: var(--yellow);
}

.visual-card-icon.blue {
  background: #eff6ff;
  color: var(--blue);
}

/* Count Display - VISUAL NOT TEXT */
.count-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 1200;
  font-size: 18px;
}

.count-display.green {
  background: var(--green);
}

.count-display.red {
  background: var(--red);
}

.count-display.yellow {
  background: var(--yellow);
}

/* ============================================
   CORE LAYOUT - Responsive
   ============================================ */
.core {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panelHeader {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 900;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

/* ============================================
   PRODUCT GRID - Responsive
   ============================================ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.p-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 80px;
}

.p-card:active {
  transform: scale(0.95);
  background: #f8fafc;
}

.p-card.cow {
  border-left: 4px solid var(--green);
}

.p-card.buff {
  border-left: 4px solid var(--red);
}

.p-card div {
  font-weight: 900;
  font-size: 13px;
}

.p-card small {
  color: var(--muted);
  font-weight: 700;
  font-size: 10px;
}

.p-card.selected {
  border: 2px solid var(--blue) !important;
  background: #eff6ff !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

/* ============================================
   TOAST - Responsive
   ============================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--status-height) + var(--bottom-height) + 32px);
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  font-weight: 900;
  font-size: 32px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 2000;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Mobile (up to 640px) */
@media (max-width: 640px) {
  :root {
    --header-height: 56px;
    --status-height: 56px;
    --bottom-height: 72px;
    --gap: 8px;
    --padding: 8px;
  }
  
  .status-item-label {
    display: none;
  }
  
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .panic-bar {
    grid-template-columns: 1fr 2fr 1fr;
  }
}

/* Tablet (641px to 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
  :root {
    --header-height: 64px;
    --status-height: 56px;
    --bottom-height: 80px;
    --gap: 10px;
    --padding: 10px;
  }
  
  .core {
    grid-template-columns: 1fr;
  }
  
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop (1025px and up) */
@media (min-width: 1025px) {
  :root {
    --header-height: 76px;
    --status-height: 56px;
    --bottom-height: 96px;
    --gap: 14px;
    --padding: 14px;
  }
  
  .core {
    grid-template-columns: 1.3fr 0.7fr;
  }
  
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .panic-bar {
    grid-template-columns: 1fr 1.4fr 1fr;
  }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  .p-card:active {
    transform: scale(0.95);
  }
  
  .panic-btn, .icon-btn, .status-item {
    min-height: 44px;
  }
}

/* Print styles */
@media print {
  .navbar, .panic-bar, .status-bar, .overlay {
    display: none !important;
  }
  
  .core {
    display: block;
  }
}
