/* Responsive Design Styles */

/* Extra Small Devices (< 475px) */
@media (max-width: 475px) {
  /* Container */
  .container {
    padding: 0 var(--space-3);
  }

  /* Typography */
  h1 {
    font-size: var(--text-3xl);
  }

  h2 {
    font-size: var(--text-2xl);
  }

  h3 {
    font-size: var(--text-xl);
  }

  h4 {
    font-size: var(--text-lg);
  }

  /* Grid */
  .grid {
    gap: var(--space-3);
  }

  /* Buttons */
  .btn {
    width: 100%;
  }

  /* App Layout */
  .app-sidebar {
    display: none;
    position: fixed;
    top: var(--header-height-mobile);
    left: 0;
    bottom: 0;
    width: 80%;
    z-index: var(--z-modal);
    box-shadow: var(--shadow-xl);
  }

  .app-sidebar.mobile-open {
    display: block;
  }

  .app-preview {
    display: none;
    position: fixed;
    top: var(--header-height-mobile);
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: var(--z-modal);
  }

  .app-preview.mobile-open {
    display: block;
  }

  /* Table Scroll */
  .results-table-wrapper {
    overflow-x: auto;
  }

  .results-table {
    min-width: 600px;
  }

  /* Modal */
  .modal {
    padding: var(--space-4);
  }

  .modal-content {
    max-width: 100%;
  }
}

/* Small Devices (640px) */
@media (max-width: 640px) {
  /* Grid Columns */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-5,
  .grid-cols-6 {
    grid-template-columns: 1fr;
  }

  /* Sections */
  .hero {
    padding: var(--space-12) 0;
  }

  .features,
  .how-it-works,
  .comparison,
  .use-cases,
  .faq-preview,
  .final-cta {
    padding: var(--space-12) 0;
  }

  /* App Sidebar */
  .app-sidebar {
    position: absolute;
    transform: translateX(-100%);
    transition: transform var(--transition-base) var(--ease-in-out);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  /* App Preview */
  .app-preview {
    position: absolute;
    right: 0;
    transform: translateX(100%);
    transition: transform var(--transition-base) var(--ease-in-out);
  }

  .app-preview.open {
    transform: translateX(0);
  }

  /* Results Table - Mobile View */
  .results-table-wrapper {
    display: none;
  }

  .results-cards {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-3);
  }

  .result-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
  }

  .result-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
  }

  .result-card-name {
    font-weight: var(--font-semibold);
    color: var(--text-primary);
  }

  .result-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-muted);
  }

  /* Forms */
  .form-group {
    margin-bottom: var(--space-3);
  }

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

  /* Footer */
  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .social-links {
    justify-content: center;
  }
}

/* Medium Devices (768px) */
@media (max-width: 768px) {
  /* Container */
  .container {
    padding: 0 var(--space-4);
  }

  /* Header */
  .header {
    height: var(--header-height-mobile);
  }

  /* Grid Columns */
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-5,
  .grid-cols-6 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Hero */
  .hero-title {
    font-size: var(--text-4xl);
  }

  .hero-subtitle {
    font-size: var(--text-lg);
  }

  .hero-actions {
    flex-direction: column;
    align-items: center;
  }

  /* Section Titles */
  .section-title {
    font-size: var(--text-3xl);
  }

  .section-subtitle {
    font-size: var(--text-base);
  }

  /* App Layout */
  .app-container {
    flex-direction: column;
  }

  .app-sidebar {
    width: 260px;
  }

  .app-preview {
    width: 100%;
    height: 300px;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  /* Results */
  .results-header {
    flex-direction: column;
    gap: var(--space-3);
    align-items: flex-start;
  }

  .results-toolbar {
    flex-direction: column;
    gap: var(--space-2);
  }

  /* Modal */
  .modal-content {
    max-width: 100%;
    margin: var(--space-4);
  }

  /* Table Responsive */
  .comparison-table {
    font-size: var(--text-sm);
  }

  .comparison-table th,
  .comparison-table td {
    padding: var(--space-2);
  }
}

/* Large Devices (1024px) */
@media (max-width: 1024px) {
  /* Container */
  .container {
    max-width: 100%;
  }

  /* Grid Columns */
  .grid-cols-4,
  .grid-cols-5,
  .grid-cols-6 {
    grid-template-columns: repeat(3, 1fr);
  }

  /* App Layout */
  .app-sidebar {
    width: 240px;
  }

  .app-preview {
    width: 350px;
  }

  /* Features Grid */
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Footer */
  .footer-content {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Extra Large Devices (1280px) */
@media (max-width: 1280px) {
  /* Container */
  .container {
    max-width: 1200px;
  }

  /* Grid Columns */
  .grid-cols-5,
  .grid-cols-6 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 2XL Devices (1536px) */
@media (max-width: 1536px) {
  /* Container */
  .container {
    max-width: 1400px;
  }
}

/* Print Styles */
@media print {
  /* Hide elements */
  .header,
  .footer,
  .app-sidebar,
  .app-preview,
  .btn,
  .modal,
  .toast-container,
  .context-menu,
  .back-to-top {
    display: none !important;
  }

  /* Adjust layout */
  .app-main {
    width: 100% !important;
  }

  .results-table-wrapper {
    height: auto !important;
    overflow: visible !important;
  }

  /* Print specific styles */
  body {
    font-size: 12pt;
    color: black;
    background: white;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }

  table {
    page-break-inside: avoid;
  }

  tr, td {
    page-break-inside: avoid;
  }
}

/* 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;
    scroll-behavior: auto !important;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --shadow-sm: 0 0 0 1px #000000;
    --shadow-md: 0 0 0 2px #000000;
    --shadow-lg: 0 0 0 3px #000000;
  }

  .btn {
    border-width: 2px;
  }

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

/* Landscape Orientation (Mobile) */
@media (max-height: 500px) and (orientation: landscape) {
  .app-header {
    height: var(--header-height-mobile);
  }

  .app-container {
    height: calc(100vh - var(--header-height-mobile));
  }

  .app-sidebar {
    padding: var(--space-2);
  }

  .sidebar-section {
    padding: var(--space-2);
  }
}

/* Tablet Specific */
@media (min-width: 768px) and (max-width: 1024px) {
  /* Optimize for touch */
  .btn {
    min-height: 44px;
  }

  .form-input,
  .form-select,
  .form-textarea {
    min-height: 44px;
  }

  .checkbox-label,
  .radio-label {
    min-height: 44px;
    padding: var(--space-2) 0;
  }

  .results-table th,
  .results-table td {
    padding: var(--space-4);
  }
}

/* Desktop Touch Screens */
@media (pointer: coarse) and (min-width: 1024px) {
  .btn {
    min-height: 48px;
    padding: var(--space-3) var(--space-5);
  }

  .icon-btn {
    width: 48px;
    height: 48px;
  }

  .form-input,
  .form-select,
  .form-textarea {
    padding: var(--space-3) var(--space-4);
  }
}

/* Responsive Utilities */
/* Hide on mobile */
@media (max-width: 640px) {
  .hide-mobile {
    display: none !important;
  }
}

/* Hide on tablet */
@media (max-width: 768px) {
  .hide-tablet {
    display: none !important;
  }
}

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

/* Show only on mobile */
.show-mobile {
  display: none !important;
}

@media (max-width: 640px) {
  .show-mobile {
    display: block !important;
  }
}

/* Show only on tablet */
.show-tablet {
  display: none !important;
}

@media (min-width: 641px) and (max-width: 1023px) {
  .show-tablet {
    display: block !important;
  }
}

/* Show only on desktop */
.show-desktop {
  display: none !important;
}

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