/* Responsive Design - Mobile-First Approach */

/* ===== Mobile Base (Default) ===== */
/* All styles in modern.css and components.css are mobile-first */

/* ===== Tablet & Up (768px+) ===== */
@media (min-width: 768px) {
  .container {
    padding: 0 var(--spacing-lg);
  }

  .navbar-content {
    flex-direction: row;
  }

  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .card {
    padding: var(--spacing-xl);
  }

  .stat-card {
    padding: var(--spacing-xl);
  }

  /* Table responsive */
  .table th,
  .table td {
    padding: 1.25rem;
  }
}

/* ===== Desktop & Up (1024px+) ===== */
@media (min-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Side-by-side layouts */
  .split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
  }

  /* Dashboard specific */
  .dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
  }
}

/* ===== Large Desktop (1280px+) ===== */
@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
  }

  h1 { font-size: 3rem; }
  h2 { font-size: 2.25rem; }
  h3 { font-size: 1.875rem; }

  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== Extra Large Desktop (1536px+) ===== */
@media (min-width: 1536px) {
  .container {
    max-width: 1400px;
  }
}

/* ===== Mobile Specific (max 767px) ===== */
@media (max-width: 767px) {
  /* Stack all grids on mobile */
  .grid,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  /* Full-width buttons on mobile */
  .btn-mobile-full {
    width: 100%;
  }

  /* Adjust card padding */
  .card {
    padding: var(--spacing-md);
  }

  /* Smaller stat cards */
  .stat-value {
    font-size: 1.75rem;
  }

  /* Stack navbar actions */
  .navbar-actions {
    width: 100%;
    justify-content: center;
  }

  /* Responsive table */
  .table-container {
    font-size: 0.875rem;
  }

  .table th,
  .table td {
    padding: 0.75rem 0.5rem;
  }

  /* Hide table columns on mobile */
  .table th.hide-mobile,
  .table td.hide-mobile {
    display: none;
  }

  /* Tabs scroll on mobile */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    flex-shrink: 0;
  }
}

/* ===== Small Mobile (max 480px) ===== */
@media (max-width: 480px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }

  .navbar-brand {
    font-size: 1.25rem;
  }

  .card-title {
    font-size: 1.25rem;
  }

  .btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
  }

  .btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
  }

  /* Smaller file upload area */
  .file-upload-area {
    padding: var(--spacing-lg);
  }

  .file-upload-icon {
    font-size: 2rem;
  }

  .file-upload-text {
    font-size: 1rem;
  }
}

/* ===== Landscape Phone ===== */
@media (max-height: 600px) and (orientation: landscape) {
  .section {
    padding: var(--spacing-md) 0;
  }

  .card {
    padding: var(--spacing-sm);
  }

  .navbar {
    padding: var(--spacing-sm) 0;
  }
}

/* ===== Print Styles ===== */
@media print {
  body {
    background: white;
    color: black;
  }

  .navbar,
  .btn,
  .toggle-switch,
  .tabs {
    display: none;
  }

  .card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .table {
    page-break-inside: auto;
  }

  .table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .table thead {
    display: table-header-group;
  }
}

/* ===== Touch Device Enhancements ===== */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .tab {
    min-height: 44px;
  }

  .toggle-switch {
    width: 60px;
    height: 30px;
  }

  .toggle-slider:before {
    height: 24px;
    width: 24px;
  }

  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(30px);
  }

  /* Remove hover effects on touch devices */
  .card:hover,
  .btn:hover,
  .stat-card:hover {
    transform: none;
  }

  /* Add active states instead */
  .btn:active {
    transform: scale(0.98);
  }

  .card:active {
    transform: scale(0.99);
  }
}

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

  .fade-in,
  .slide-in {
    animation: none;
  }

  .spinner {
    animation: none;
    border-top-color: transparent;
    border-right-color: var(--primary-indigo);
  }
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
  .card {
    border: 2px solid currentColor;
  }

  .btn {
    border: 2px solid currentColor;
  }

  .form-input,
  .form-select,
  .form-textarea {
    border: 2px solid currentColor;
  }
}

/* ===== Dark Mode Preference ===== */
@media (prefers-color-scheme: dark) {
  body:not(.light-mode) {
    background: var(--gradient-dark);
    color: var(--dark-text);
  }

  body:not(.light-mode) .glass {
    background: rgba(45, 55, 72, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  body:not(.light-mode) .card {
    background: rgba(45, 55, 72, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
  }

  body:not(.light-mode) .stat-card {
    background: var(--dark-card);
    color: var(--dark-text);
  }

  body:not(.light-mode) .form-input,
  body:not(.light-mode) .form-select,
  body:not(.light-mode) .form-textarea {
    background: rgba(45, 55, 72, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--dark-text);
  }
}
