/* ═══════════════════════════════════════════════════════════
   VALORYS — Responsive Design System
   Mobile-First Approach (375px → 768px → 1024px → 1920px)
   ═══════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────
   MOBILE (< 768px)
   ────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  /* Base */
  html, body {
    font-size: 14px;
  }

  /* Spacing */
  :root {
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;
    --spacing-2xl: 24px;
  }

  /* Typography */
  h1 { font-size: 1.8rem !important; }
  h2 { font-size: 1.4rem !important; }
  h3 { font-size: 1.1rem !important; }
  h4 { font-size: 1rem !important; }

  /* Header */
  .header {
    height: 56px;
    padding: 0 12px !important;
  }

  .header-nav {
    display: none !important;
  }

  .header-brand {
    gap: 6px;
    font-size: 0.95rem;
  }

  .header-brand img {
    height: 24px;
  }

  /* Navigation */
  .nav-mobile,
  .mobile-menu-toggle {
    display: flex !important;
  }

  .nav-desktop {
    display: none !important;
  }

  /* Layout */
  .container {
    padding: 0 12px !important;
  }

  .split-container {
    flex-direction: column !important;
  }

  .left-panel,
  .right-panel {
    width: 100% !important;
    min-height: auto;
    padding: 16px !important;
  }

  .left-panel {
    padding: 20px 16px !important;
  }

  .right-panel {
    padding: 20px 16px !important;
  }

  /* Grid */
  .grid2 {
    grid-template-columns: 1fr !important;
  }

  .grid3 {
    grid-template-columns: 1fr !important;
  }

  .grid4 {
    grid-template-columns: 1fr !important;
  }

  /* Sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 100% !important;
    height: 100vh;
    z-index: 999;
    transition: left 0.3s ease;
    overflow-y: auto;
  }

  .sidebar.open {
    left: 0;
  }

  .app {
    grid-template-columns: 1fr !important;
  }

  /* Forms */
  input,
  select,
  textarea {
    font-size: 16px !important; /* Prevent zoom on iOS */
  }

  .form-card {
    padding: 12px !important;
  }

  /* Buttons */
  .btn {
    width: 100%;
    padding: 12px 16px !important;
  }

  .btn-group {
    flex-direction: column;
  }

  /* Cards */
  .card {
    padding: 12px !important;
    margin-bottom: 8px !important;
  }

  /* Tables */
  table {
    font-size: 0.8rem;
  }

  table thead {
    display: none;
  }

  table tr {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    border-bottom: 2px solid var(--border);
    padding: 12px 0;
  }

  table td {
    display: grid;
    grid-template-columns: 100px 1fr;
    align-items: center;
    border: none;
    padding: 8px 0;
  }

  table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
  }

  /* Hero */
  .hero-title {
    font-size: 1.6rem !important;
  }

  .hero-subtitle {
    font-size: 0.95rem !important;
  }

  /* Stats */
  .stats-container {
    flex-direction: column;
    gap: 16px;
  }

  /* Modals */
  .modal {
    width: 90vw !important;
    max-width: 90vw !important;
  }

  /* Dropdowns */
  .dropdown-menu {
    max-width: 80vw !important;
  }
}

/* ──────────────────────────────────────────────────────────
   TABLET (768px - 1023px)
   ────────────────────────────────────────────────────────── */

@media (min-width: 768px) and (max-width: 1023px) {
  /* Typography */
  h1 { font-size: 2rem !important; }
  h2 { font-size: 1.6rem !important; }
  h3 { font-size: 1.2rem !important; }

  /* Layout */
  .container {
    max-width: 728px;
    margin: 0 auto;
  }

  /* Grid */
  .grid3 {
    grid-template-columns: 1fr 1fr !important;
  }

  .grid4 {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Sidebar */
  .sidebar {
    width: 100px !important;
  }

  .sidebar.expanded {
    width: 200px !important;
  }

  .label {
    display: none;
  }

  .sidebar:hover .label {
    display: inline;
  }

  /* Split panel */
  .split-container {
    flex-direction: column !important;
  }

  .left-panel,
  .right-panel {
    width: 100% !important;
  }

  /* Hero */
  .hero-title {
    font-size: 2rem !important;
  }

  .hero-subtitle {
    font-size: 1rem !important;
  }
}

/* ──────────────────────────────────────────────────────────
   DESKTOP (1024px - 1439px)
   ────────────────────────────────────────────────────────── */

@media (min-width: 1024px) and (max-width: 1439px) {
  .container {
    max-width: 960px;
    margin: 0 auto;
  }

  /* Layout adjustments */
  .grid4 {
    grid-template-columns: 1fr 1fr 1fr !important;
  }
}

/* ──────────────────────────────────────────────────────────
   DESKTOP XL (≥ 1440px)
   ────────────────────────────────────────────────────────── */

@media (min-width: 1440px) {
  .container {
    max-width: 1200px;
    margin: 0 auto;
  }

  /* Typography */
  h1 { font-size: 2.5rem !important; }
  h2 { font-size: 2rem !important; }
  h3 { font-size: 1.5rem !important; }
}

/* ──────────────────────────────────────────────────────────
   ORIENTATION: LANDSCAPE
   ────────────────────────────────────────────────────────── */

@media (orientation: landscape) and (max-height: 600px) {
  header,
  .header {
    height: 48px;
  }

  main,
  .main {
    margin-top: 48px;
  }

  .hero-section {
    min-height: auto;
    padding: 20px 0;
  }

  h1 {
    font-size: 1.5rem !important;
  }
}

/* ──────────────────────────────────────────────────────────
   PRINT
   ────────────────────────────────────────────────────────── */

@media print {
  header, footer, nav, .no-print {
    display: none !important;
  }

  .container {
    max-width: 100%;
  }

  body {
    background: white;
    color: black;
  }

  a {
    text-decoration: underline;
  }

  .page-break {
    page-break-after: always;
  }
}

/* ──────────────────────────────────────────────────────────
   HIGH RESOLUTION (≥ 2x DPI)
   ────────────────────────────────────────────────────────── */

@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
  /* Better font rendering */
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* ──────────────────────────────────────────────────────────
   ACCESSIBILITY: PREFERS REDUCED MOTION
   ────────────────────────────────────────────────────────── */

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

/* ──────────────────────────────────────────────────────────
   ACCESSIBILITY: HIGH CONTRAST
   ────────────────────────────────────────────────────────── */

@media (prefers-contrast: more) {
  :root {
    --border: rgba(0, 255, 163, 0.4) !important;
    --muted: rgba(255, 255, 255, 0.8) !important;
  }

  button, a {
    text-decoration: underline;
  }
}

/* ──────────────────────────────────────────────────────────
   TOUCH DEVICES: LARGER TOUCH TARGETS
   ────────────────────────────────────────────────────────── */

@media (hover: none) and (pointer: coarse) {
  button,
  a,
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 44px;
    min-height: 44px;
  }

  .btn {
    padding: 14px 20px !important;
  }

  select,
  input,
  textarea {
    font-size: 16px !important; /* Prevent iOS zoom */
  }
}

/* ──────────────────────────────────────────────────────────
   UTILITY: RESPONSIVE DISPLAY CLASSES
   ────────────────────────────────────────────────────────── */

.hide-mobile {
  display: none;
}

.hide-tablet {
  display: block;
}

.hide-desktop {
  display: block;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: block !important;
  }

  .hide-tablet {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  .hide-desktop {
    display: none !important;
  }
}

/* Responsive utilities */
.w-100 { width: 100%; }
.max-w-mobile { max-width: 100vw; }
.max-w-tablet { max-width: 768px; }
.max-w-desktop { max-width: 1200px; }

@media (max-width: 767px) {
  .flex-row {
    flex-direction: column;
  }

  .gap-lg {
    gap: 8px !important;
  }

  .p-lg {
    padding: 12px !important;
  }

  .m-lg {
    margin: 12px !important;
  }
}
