/**
 * ════════════════════════════════════════════════════════════════════════════════
 * VELLUNOX MOBILE RESPONSIVE - Works on ALL Devices
 * iPhone, Android, iPad, Tablet, Desktop, TV, VR
 * ════════════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════
   BASE MOBILE FIXES
   ═══════════════════════════════════════════════════════════════════════════ */

/* Prevent horizontal scrolling */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Make all images responsive */
img {
  max-width: 100%;
  height: auto;
}

/* Make all videos responsive */
video, iframe {
  max-width: 100%;
  height: auto;
}

/* Prevent text from overflowing */
* {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTAINER FIXES
   ═══════════════════════════════════════════════════════════════════════════ */

.container,
.main-container,
.content-container,
.page-container,
.dashboard-container {
  width: 100%;
  max-width: 100%;
  padding-left: 16px;
  padding-right: 16px;
  box-sizing: border-box;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORM INPUTS - iOS Safari Zoom Fix
   ═══════════════════════════════════════════════════════════════════════════ */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
textarea,
select {
  font-size: 16px !important; /* Prevents iOS zoom on focus */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TABLET (768px and below)
   ═══════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
  /* Navigation */
  nav, .nav, .navbar, .navigation {
    flex-wrap: wrap !important;
    padding: 8px 12px !important;
  }
  
  .nav-links, .navbar-links, .menu-links {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  /* Sidebar becomes bottom nav */
  .sidebar, .side-nav, .side-menu {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    z-index: 1000 !important;
    border-top: 1px solid rgba(255,255,255,0.1) !important;
    border-right: none !important;
    padding: 8px !important;
  }
  
  /* Main content adjusts for bottom nav */
  main, .main, .main-content, .content {
    padding-bottom: 80px !important;
    margin-left: 0 !important;
  }
  
  /* Grid layouts become single column */
  .grid, .grid-2, .grid-3, .grid-4,
  [class*="grid-cols-"],
  .row, .flex-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }
  
  /* Cards */
  .card, .panel, .box, [class*="card"] {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  /* Buttons */
  .btn, .button, [class*="btn-"] {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
  
  /* Tables - horizontal scroll */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Modals */
  .modal, .popup, .dialog, [class*="modal"] {
    width: 95% !important;
    max-width: 95% !important;
    margin: 10px auto !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
  
  /* Typography scaling */
  h1 { font-size: 1.75rem !important; }
  h2 { font-size: 1.5rem !important; }
  h3 { font-size: 1.25rem !important; }
  h4 { font-size: 1.1rem !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SMALL PHONES (480px and below) - iPhone SE, small Androids
   ═══════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 480px) {
  body {
    font-size: 14px;
  }
  
  h1 { font-size: 1.5rem !important; }
  h2 { font-size: 1.25rem !important; }
  h3 { font-size: 1.1rem !important; }
  h4 { font-size: 1rem !important; }
  
  /* Tighter padding */
  .container,
  .main-container,
  .content-container {
    padding-left: 12px;
    padding-right: 12px;
  }
  
  /* Cards more compact */
  .card, .panel, .box {
    padding: 12px !important;
  }
  
  /* Smaller buttons but still touch-friendly */
  .btn, .button {
    padding: 10px 16px !important;
    font-size: 0.9rem !important;
  }
  
  /* Stats compact */
  .stat-value, .metric-value, .number-big {
    font-size: 1.5rem !important;
  }
  
  /* Hide non-essential elements */
  .desktop-only, .hide-mobile {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   EXTRA SMALL (320px) - iPhone 5/SE first gen
   ═══════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 320px) {
  body {
    font-size: 13px;
  }
  
  h1 { font-size: 1.25rem !important; }
  h2 { font-size: 1.1rem !important; }
  
  .container,
  .main-container {
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOUCH DEVICES - Better touch targets
   ═══════════════════════════════════════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
  /* Minimum touch target size (Apple HIG) */
  a, button, .btn, .button,
  input[type="submit"],
  input[type="button"],
  input[type="checkbox"],
  input[type="radio"],
  .nav-item, .menu-item,
  .clickable, [onclick] {
    min-height: 44px !important;
    min-width: 44px !important;
  }
  
  /* Disable hover effects */
  *:hover {
    transform: none !important;
  }
  
  /* Active state instead of hover */
  .btn:active, .button:active,
  .card:active, a:active {
    opacity: 0.8;
    transform: scale(0.98) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LANDSCAPE ORIENTATION
   ═══════════════════════════════════════════════════════════════════════════ */

@media screen and (max-height: 500px) and (orientation: landscape) {
  /* Reduce vertical space */
  .header, .nav, nav {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
  
  .sidebar {
    max-height: 50px !important;
  }
  
  main, .main-content {
    padding-top: 50px !important;
    padding-bottom: 60px !important;
  }
  
  h1 { font-size: 1.25rem !important; }
  h2 { font-size: 1.1rem !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE SUPPORT (for system preference)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  /* Already dark theme, but ensure consistency */
  img {
    filter: brightness(0.95);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION (accessibility)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SAFE AREA INSETS (iPhone X+ notch, home indicator)
   ═══════════════════════════════════════════════════════════════════════════ */

@supports (padding: max(0px)) {
  body {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  
  .sidebar, .bottom-nav, .footer {
    padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT STYLES (for PDF export, printing)
   ═══════════════════════════════════════════════════════════════════════════ */

@media print {
  .sidebar, .nav, .footer, .bottom-nav,
  .floating-ops, .chat-widget, .fab,
  button:not(.print-btn) {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
  
  .card, .panel {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════════ */

.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

@media screen and (max-width: 768px) {
  .mobile-only {
    display: block !important;
  }
  
  .desktop-only {
    display: none !important;
  }
}

.touch-scroll {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

.no-scroll {
  overflow: hidden !important;
}

.full-width {
  width: 100% !important;
  max-width: 100% !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BRAIN HOLOGRAM / STATS PANEL RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

/* On screens smaller than 1200px, move brain to corner and make smaller */
@media screen and (max-width: 1200px) {
  .vellunox-brain-container {
    width: 150px !important;
    height: 150px !important;
    bottom: 80px !important;
    right: 10px !important;
  }
  
  .vellunox-brain-container.expanded {
    width: 320px !important;
    height: 400px !important;
    right: 10px !important;
    bottom: 80px !important;
  }
}

/* On tablets, make even smaller */
@media screen and (max-width: 992px) {
  .vellunox-brain-container {
    width: 100px !important;
    height: 100px !important;
    bottom: 70px !important;
    right: 8px !important;
  }
  
  .vellunox-brain-container.expanded {
    width: 280px !important;
    height: 350px !important;
  }
  
  /* Hide expanded content labels */
  .brain-expanded-content .brain-metric-label {
    font-size: 0.6rem !important;
  }
}

/* On mobile phones, collapse to mini version */
@media screen and (max-width: 768px) {
  .vellunox-brain-container {
    width: 60px !important;
    height: 60px !important;
    bottom: 90px !important;
    right: 8px !important;
  }
  
  .vellunox-brain-container .brain-overlay {
    display: none !important;
  }
  
  .vellunox-brain-container.expanded {
    width: calc(100vw - 20px) !important;
    height: 300px !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 80px !important;
  }
  
  .vellunox-brain-container.expanded .brain-overlay {
    display: block !important;
  }
}

/* Very small screens - hide brain entirely or make it tiny */
@media screen and (max-width: 480px) {
  .vellunox-brain-container:not(.expanded) {
    width: 50px !important;
    height: 50px !important;
    bottom: 85px !important;
    opacity: 0.7;
  }
  
  .vellunox-brain-container.expanded {
    height: 250px !important;
  }
  
  .brain-metrics-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }
  
  .brain-metric {
    padding: 0.5rem !important;
  }
  
  .brain-metric-value {
    font-size: 1rem !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   HERO SECTION RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 1200px) {
  .hero-section,
  .hero,
  [class*="hero"] {
    padding-right: 200px !important; /* Make room for brain panel */
  }
}

@media screen and (max-width: 992px) {
  .hero-section,
  .hero,
  [class*="hero"] {
    padding-right: 120px !important;
  }
}

@media screen and (max-width: 768px) {
  .hero-section,
  .hero,
  [class*="hero"] {
    padding-right: 16px !important;
    padding-left: 16px !important;
    text-align: center !important;
  }
  
  .hero h1,
  .hero-section h1,
  [class*="hero"] h1 {
    font-size: 1.75rem !important;
    line-height: 1.3 !important;
  }
  
  .hero p,
  .hero-section p {
    font-size: 1rem !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FLOATING ELEMENTS RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
  /* Santa FAB button */
  .santa-fab,
  .floating-action-button,
  [class*="fab"] {
    width: 50px !important;
    height: 50px !important;
    bottom: 90px !important;
    left: 10px !important;
    right: auto !important;
  }
  
  /* Founders prompt */
  .founders-promotion,
  .promo-banner,
  [class*="promo"] {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 50vh !important;
    overflow-y: auto !important;
  }
}

