/**
 * FILE: public/css/style.css
 * PURPOSE: 3D Dark Purple Theme - Main Stylesheet
 * 
 * DESIGN SYSTEM:
 *   - Theme: Dark Purple with 3D Effects
 *   - Primary: #7C3AED (Purple-600)
 *   - Background: #0A0A0A (Deep Black)
 *   - Surface: #1A1A1A (Dark Gray)
 *   - 3D Effects: Layered shadows, transforms, gradients
 * 
 * LAST UPDATED: 2025-12-29
 */

/* ========================================
   ROOT VARIABLES
   ======================================== */
:root {
  /* Colors */
  --color-primary: #7C3AED;
  --color-primary-light: #A78BFA;
  --color-primary-dark: #5B21B6;
  --color-secondary: #C084FC;
  --color-accent: #E9D5FF;
  
  --color-bg: #0A0A0A;
  --color-surface: #1A1A1A;
  --color-surface-light: #252525;
  --color-border: #2D2D2D;
  --color-border-light: #3D3D3D;
  
  --color-text: #E5E5E5;
  --color-text-muted: #A0A0A0;
  --color-text-dark: #707070;
  
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-error: #EF4444;
  --color-info: #3B82F6;
  
  /* 3D Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.6), 0 2px 4px rgba(124, 58, 237, 0.2);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.7), 0 4px 8px rgba(124, 58, 237, 0.3);
  --shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.8), 0 6px 12px rgba(124, 58, 237, 0.4);
  --shadow-2xl: 0 20px 40px rgba(0, 0, 0, 0.9), 0 10px 20px rgba(124, 58, 237, 0.5);
  
  /* Glow Effects */
  --glow-purple: 0 0 20px rgba(124, 58, 237, 0.5);
  --glow-purple-strong: 0 0 30px rgba(124, 58, 237, 0.8);
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
}

/* ========================================
   RESET & BASE
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========================================
   3D CARD STYLES
   ======================================== */
.card-3d {
  background: linear-gradient(145deg, var(--color-surface), var(--color-surface-light));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-lg);
  transform: translateZ(0);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card-3d::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
  opacity: 0.5;
}

.card-3d:hover {
  transform: translateY(-4px) translateZ(0);
  box-shadow: var(--shadow-xl), var(--glow-purple);
  border-color: var(--color-primary);
}

.card-3d-pressed {
  transform: translateY(2px) translateZ(0);
  box-shadow: var(--shadow-md);
}

/* ========================================
   3D BUTTON STYLES
   ======================================== */
.btn-3d {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  transform: translateZ(0);
}

.btn-3d::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left var(--transition-slow);
}

.btn-3d:hover::before {
  left: 100%;
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  box-shadow: var(--shadow-md), 0 4px 0 var(--color-primary-dark);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--glow-purple), 0 6px 0 var(--color-primary-dark);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-sm), 0 2px 0 var(--color-primary-dark);
}

/* Secondary Button */
.btn-secondary {
  background: linear-gradient(135deg, var(--color-surface-light), var(--color-surface));
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm), 0 3px 0 var(--color-border);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 5px 0 var(--color-border);
  border-color: var(--color-primary);
}

.btn-secondary:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-sm), 0 1px 0 var(--color-border);
}

/* Danger Button */
.btn-danger {
  background: linear-gradient(135deg, var(--color-error), #DC2626);
  color: white;
  box-shadow: var(--shadow-md), 0 4px 0 #DC2626;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(239, 68, 68, 0.5), 0 6px 0 #DC2626;
}

.btn-danger:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-sm), 0 2px 0 #DC2626;
}

/* Success Button */
.btn-success {
  background: linear-gradient(135deg, var(--color-success), #059669);
  color: white;
  box-shadow: var(--shadow-md), 0 4px 0 #059669;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(16, 185, 129, 0.5), 0 6px 0 #059669;
}

.btn-success:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-sm), 0 2px 0 #059669;
}

/* Warning Button */
.btn-warning {
  background: linear-gradient(135deg, var(--color-warning), #F59E0B);
  color: white;
  box-shadow: var(--shadow-md), 0 4px 0 #F59E0B;
}

.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(245, 158, 11, 0.5), 0 6px 0 #F59E0B;
}

.btn-warning:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-sm), 0 2px 0 #F59E0B;
}

/* Info Button */
.btn-info {
  background: linear-gradient(135deg, var(--color-info), #2563EB);
  color: white;
  box-shadow: var(--shadow-md), 0 4px 0 #2563EB;
}

.btn-info:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(59, 130, 246, 0.5), 0 6px 0 #2563EB;
}

.btn-info:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-sm), 0 2px 0 #2563EB;
}

/* Button Color Classes (for specific use cases) */
.btn-logout {
  background: linear-gradient(135deg, var(--color-error), #DC2626) !important;
  color: white !important;
  box-shadow: var(--shadow-md), 0 4px 0 #DC2626 !important;
  width: 140px;
  height: 40px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

.btn-logout:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(239, 68, 68, 0.5), 0 6px 0 #DC2626 !important;
}

.btn-logout:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-sm), 0 2px 0 #DC2626 !important;
}

.btn-login-employee {
  background: linear-gradient(135deg, var(--color-success), #059669) !important;
  color: white !important;
  box-shadow: var(--shadow-md), 0 4px 0 #059669 !important;
  width: 100%;
  height: 40px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  justify-content: center;
  white-space: nowrap;
}

.btn-login-employee:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(16, 185, 129, 0.5), 0 6px 0 #059669 !important;
}

.btn-login-employee:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-sm), 0 2px 0 #059669 !important;
}

.btn-login-admin {
  background: linear-gradient(135deg, var(--color-info), #2563EB) !important;
  color: white !important;
  box-shadow: var(--shadow-md), 0 4px 0 #2563EB !important;
  width: 140px;
  height: 40px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  justify-content: center;
  white-space: nowrap;
}

.btn-login-admin:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(59, 130, 246, 0.5), 0 6px 0 #2563EB !important;
}

.btn-login-admin:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-sm), 0 2px 0 #2563EB !important;
}

/* Button Sizes */
.btn-sm {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: 0.75rem;
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: 1rem;
}

/* Popup Button Styles */
#logout-popup .btn-3d,
#otp-modal .btn-3d {
  width: 100%;
  justify-content: center;
}

/* ========================================
   3D INPUT STYLES
   ======================================== */
.input-3d {
  width: 100%;
  padding: var(--spacing-md);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 0.875rem;
  transition: all var(--transition-base);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.input-3d:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), var(--glow-purple);
  transform: translateY(-1px);
}

.input-3d::placeholder {
  color: var(--color-text-dark);
}

/* ========================================
   LAYOUT
   ======================================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.main-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--color-surface), var(--color-bg));
  border-right: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: var(--spacing-xl);
  min-height: 100vh;
}

/* ========================================
   HEADER
   ======================================== */
.header-3d {
  background: linear-gradient(135deg, var(--color-surface), var(--color-surface-light));
  border-bottom: 1px solid var(--color-border);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ========================================
   NAVIGATION
   ======================================== */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  margin: var(--spacing-xs) var(--spacing-md);
  transition: all var(--transition-base);
  position: relative;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--color-primary);
  border-radius: 0 3px 3px 0;
  transition: height var(--transition-base);
}

.nav-item:hover {
  background: var(--color-surface-light);
  color: var(--color-text);
  transform: translateX(4px);
}

.nav-item:hover::before {
  height: 60%;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.2), transparent);
  color: var(--color-primary-light);
  box-shadow: var(--shadow-sm);
}

.nav-item.active::before {
  height: 80%;
}

/* ========================================
   UTILITIES
   ======================================== */
.text-primary { color: var(--color-primary-light); }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }

.p-1 { padding: var(--spacing-sm); }
.p-2 { padding: var(--spacing-md); }
.p-3 { padding: var(--spacing-lg); }
.p-4 { padding: var(--spacing-xl); }

/* ========================================
   RESPONSIVE - MOBILE FIRST
   ======================================== */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg), var(--glow-purple);
  transition: all var(--transition-fast);
  align-items: center;
  justify-content: center;
}

.mobile-menu-toggle:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-xl), var(--glow-purple-strong);
}

.mobile-menu-toggle:active {
  transform: scale(0.95);
}

/* Mobile Overlay */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  pointer-events: none; /* ไม่บล็อกการคลิกเมื่อไม่ active */
  transition: opacity var(--transition-base);
}

.mobile-overlay.active {
  opacity: 1;
  pointer-events: auto; /* บล็อกการคลิกเฉพาะเมื่อ active */
}

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }
  
  .main-content {
    margin-left: 220px;
    padding: var(--spacing-lg);
  }
  
  /* Stats cards - 2 columns on tablet */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
  /* ป้องกัน overflow - สำคัญมาก! */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  
  * {
    max-width: 100vw;
  }
  
  .main-wrapper {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  /* Show mobile menu toggle */
  .mobile-menu-toggle {
    display: flex;
  }
  
  /* Show mobile overlay */
  .mobile-overlay {
    display: block;
    pointer-events: none; /* ไม่บล็อกการคลิกเมื่อไม่ active */
  }
  
  .mobile-overlay.active {
    pointer-events: auto; /* บล็อกการคลิกเฉพาะเมื่อ active */
  }
  
  /* Sidebar - slide from left */
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    box-shadow: var(--shadow-2xl);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  /* Main content - full width */
  .main-content {
    margin-left: 0;
    padding: 0.5rem;
    padding-top: 4rem; /* Space for mobile menu button */
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
  
  /* Header adjustments */
  .header-3d {
    padding: 0.5rem;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  .header-3d h2 {
    font-size: 1.1rem !important;
  }
  
  .header-3d p {
    font-size: 0.7rem !important;
    display: none; /* ซ่อน description บน mobile */
  }
  
  /* Header buttons - ลดขนาด */
  .header-3d .btn-3d {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.7rem !important;
    min-height: 32px !important;
  }
  
  .header-3d [style*="display: flex"][style*="gap"] {
    gap: 0.25rem !important;
  }
  
  /* ===== STATS CARDS - 2 COLUMNS บน MOBILE ===== */
  /* Target inline style grid */
  [style*="grid-template-columns: repeat(auto-fit, minmax(220px"] {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }
  
  /* Stats cards - ลดขนาด padding และ font บน mobile */
  [style*="grid-template-columns: repeat(auto-fit, minmax(220px"] > .card-3d {
    padding: 0.5rem !important;
  }
  
  /* Stats card inner flex container */
  [style*="grid-template-columns: repeat(auto-fit, minmax(220px"] > .card-3d > div {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }
  
  /* Stats numbers - ลดขนาด */
  [style*="grid-template-columns: repeat(auto-fit, minmax(220px"] h3[style*="font-size: 2rem"] {
    font-size: 1.2rem !important;
  }
  
  /* Stats labels - ลดขนาด */
  [style*="grid-template-columns: repeat(auto-fit, minmax(220px"] p[style*="font-size: 0.875rem"] {
    font-size: 0.65rem !important;
    margin-bottom: 0.25rem !important;
  }
  
  /* Stats icon - ลดขนาดบน mobile */
  [style*="width: 48px"][style*="height: 48px"] {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
  }
  
  [style*="width: 48px"][style*="height: 48px"] i {
    font-size: 0.8rem !important;
  }
  
  /* ===== BANK ACCOUNT CARD - 2 COLUMNS บน MOBILE ===== */
  /* Bank card grid - keep 2 columns but smaller */
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"][style*="min-height: 200px"] {
    grid-template-columns: 1fr 1fr !important;
    min-height: auto !important;
    gap: 0 !important;
  }
  
  /* Bank card sections - ลด padding */
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] > div[style*="padding: 1.5rem"] {
    padding: 0.5rem !important;
  }
  
  /* Bank card text - ลดขนาด */
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] h3 {
    font-size: 0.8rem !important;
  }
  
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] h4 {
    font-size: 0.75rem !important;
  }
  
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] p {
    font-size: 0.6rem !important;
  }
  
  /* Bank balance - ลดขนาด */
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] p[style*="font-size: 1.25rem"] {
    font-size: 0.9rem !important;
  }
  
  /* Bank card icons - ลดขนาด */
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] [style*="width: 48px"][style*="height: 48px"],
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] [style*="width: 64px"][style*="height: 64px"] {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    margin-bottom: 0.5rem !important;
  }
  
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] [style*="width: 48px"] i,
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] [style*="width: 64px"] i {
    font-size: 1rem !important;
  }
  
  /* Bank card buttons - ลดขนาด */
  [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"] .btn-3d {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.6rem !important;
    min-height: 28px !important;
    min-width: auto !important;
    width: auto !important;
  }
  
  /* Hide vertical divider on mobile */
  [style*="position: absolute; left: 50%"][style*="width: 3px"] {
    display: none !important;
  }
  
  /* Card adjustments */
  .card-3d {
    padding: var(--spacing-md);
  }
  
  /* Table responsive - horizontal scroll */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  table th,
  table td {
    padding: 0.5rem !important;
    font-size: 0.75rem !important;
  }
  
  /* Buttons - keep auto width, don't force full width */
  .btn-3d.btn-full-mobile {
    width: 100%;
    justify-content: center;
  }
  
  /* Only stack specific button groups, not all flex containers */
  .btn-stack-mobile {
    flex-direction: column !important;
  }
  
  /* Keep some button groups horizontal */
  .btn-group-horizontal {
    flex-direction: row !important;
    flex-wrap: wrap;
  }
  
  /* Popup adjustments */
  [style*="max-width: 400px"],
  [style*="max-width: 500px"] {
    max-width: 95% !important;
    margin: 1rem !important;
  }
  
  /* Form inputs */
  .input-3d {
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  /* Navigation items */
  .nav-item {
    padding: var(--spacing-md);
    font-size: 0.9rem;
  }
  
  /* System status grid - 2 columns */
  [style*="grid-template-columns: repeat(auto-fit, minmax(200px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }
  
  /* System status cards - ลดขนาด */
  [style*="grid-template-columns: repeat(auto-fit, minmax(200px"] > div {
    padding: 0.5rem !important;
  }
  
  [style*="grid-template-columns: repeat(auto-fit, minmax(200px"] p[style*="font-size: 1.25rem"] {
    font-size: 0.9rem !important;
  }
  
  /* Notification container */
  #notification-container {
    left: 1rem !important;
    right: 1rem !important;
    max-width: none !important;
    pointer-events: auto !important;
  }
  
  /* Toast notifications */
  .toast-3d {
    min-width: auto !important;
    max-width: none !important;
    pointer-events: auto !important;
  }
  
  /* Contact popup adjustments */
  #contact-popup .card-3d {
    max-height: 90vh;
    overflow-y: auto;
  }
  
  /* Logout popup adjustments */
  #logout-popup .card-3d {
    max-height: 90vh;
    overflow-y: auto;
  }
  
  /* Popup close buttons - ensure clickable */
  [style*="position: fixed"] button,
  .card-3d button {
    pointer-events: auto !important;
    z-index: 10;
  }
  
  /* Recent Orders section - ลดขนาด */
  .card-3d h3[style*="font-size: 1.25rem"] {
    font-size: 1rem !important;
  }
  
  /* Recent Orders buttons */
  .card-3d [style*="display: flex"][style*="gap: 0.75rem"] {
    gap: 0.25rem !important;
  }
  
  .card-3d [style*="display: flex"][style*="gap: 0.75rem"] .btn-3d {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.65rem !important;
  }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
  /* Even smaller padding */
  .main-content {
    padding: var(--spacing-sm);
    padding-top: 4.5rem;
  }
  
  /* Smaller cards */
  .card-3d {
    padding: var(--spacing-sm);
  }
  
  /* Smaller text */
  h3 {
    font-size: 1rem !important;
  }
  
  /* Stats numbers */
  [style*="font-size: 2rem"] {
    font-size: 1.5rem !important;
  }
  
  /* System status - single column */
  [style*="grid-template-columns: repeat(auto-fit, minmax(200px"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Table - card view for very small screens */
  .table-card-view tbody tr {
    display: block;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }
  
  .table-card-view tbody td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0 !important;
    border-bottom: 1px solid var(--color-border);
    white-space: normal !important;
  }
  
  .table-card-view tbody td:last-child {
    border-bottom: none;
  }
  
  .table-card-view tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-muted);
  }
  
  .table-card-view thead {
    display: none;
  }
  
  /* Mobile menu button smaller */
  .mobile-menu-toggle {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
  }
  
  /* Popup buttons */
  .popup-buttons {
    flex-direction: column !important;
  }
  
  .popup-buttons .btn-3d {
    width: 100% !important;
  }
  
  /* Ensure all buttons in popups are clickable */
  [style*="position: fixed"] .btn-3d,
  [style*="z-index: 9999"] .btn-3d,
  [style*="z-index: 10000"] .btn-3d {
    pointer-events: auto !important;
  }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .main-content {
    padding-top: 4rem;
  }
  
  .mobile-menu-toggle {
    top: 0.5rem;
    left: 0.5rem;
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  /* Reduce popup heights */
  [style*="position: fixed"][style*="z-index: 9999"] .card-3d,
  [style*="position: fixed"][style*="z-index: 10000"] .card-3d {
    max-height: 85vh;
    overflow-y: auto;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .btn-3d {
    min-height: 44px;
    padding: var(--spacing-md) var(--spacing-lg);
  }
  
  .nav-item {
    min-height: 48px;
  }
  
  /* Remove hover effects that don't work well on touch */
  .card-3d:hover {
    transform: none;
  }
  
  .btn-3d:hover {
    transform: none;
  }
  
  /* Active states instead */
  .btn-3d:active {
    transform: scale(0.98);
  }
  
  .card-3d:active {
    transform: scale(0.99);
  }
}

/* Print styles */
@media print {
  .sidebar,
  .mobile-menu-toggle,
  .mobile-overlay,
  .btn-3d,
  #notification-container {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  
  .card-3d {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
  }
}


/* ========================================
   SWITCH TOGGLE STYLES
   ======================================== */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-border);
  transition: var(--transition-base);
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: var(--transition-base);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
}

input:checked + .slider:before {
  transform: translateX(22px);
}

input:focus + .slider {
  box-shadow: var(--glow-purple);
}

/* ========================================
   ADDITIONAL MOBILE RESPONSIVE FIXES
   ======================================== */

/* Settings page responsive */
@media (max-width: 768px) {
  /* Switch container */
  [style*="display: flex"][style*="align-items: center"][style*="gap: 1rem"][style*="padding: 1rem"] {
    flex-wrap: wrap;
  }
  
  /* Input fields full width */
  .input-3d,
  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  input[type="date"],
  select {
    width: 100% !important;
    min-width: 0 !important;
  }
  
  /* Search bar responsive */
  #search-input,
  #search-date,
  #search-type {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* Orders list responsive */
@media (max-width: 768px) {
  /* Action buttons in table */
  .action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .action-buttons .btn-3d {
    width: 100%;
    font-size: 0.75rem;
    padding: 0.5rem;
  }
}

/* Bank login page responsive */
@media (max-width: 768px) {
  .login-container {
    padding: 1rem !important;
  }
  
  .login-card {
    padding: 1.5rem !important;
  }
}

/* API page responsive */
@media (max-width: 768px) {
  /* Code blocks */
  pre, code {
    font-size: 0.75rem !important;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
  }
}

/* Users page responsive */
@media (max-width: 768px) {
  /* User cards */
  .user-card {
    padding: 1rem !important;
  }
  
  .user-card .btn-3d {
    width: 100%;
    margin-top: 0.5rem;
  }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
  /* Prevent zoom on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }
  
  /* Fix for 100vh on iOS */
  .main-wrapper {
    min-height: -webkit-fill-available;
  }
}

/* Scrollbar styling for mobile */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
  
  ::-webkit-scrollbar-track {
    background: var(--color-surface);
  }
  
  ::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
  }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
  .main-content {
    padding-left: max(var(--spacing-md), env(safe-area-inset-left));
    padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    padding-bottom: max(var(--spacing-md), env(safe-area-inset-bottom));
  }
  
  .sidebar {
    padding-bottom: max(var(--spacing-md), env(safe-area-inset-bottom));
  }
  
  .mobile-menu-toggle {
    left: max(1rem, env(safe-area-inset-left));
    top: max(1rem, env(safe-area-inset-top));
  }
}
