/**
 * ChickenTandy - Responsive Styles
 * Mobile-first responsive design
 */

/* ========================================
   MOBILE FIRST BASE (20rem+)
   ======================================== */

/* Base styles are already mobile-first in main.css */

/* Touch-friendly defaults for mobile */
@media (max-width: 47.9375rem) {
  :root {
    --container-padding: var(--space-4);
    --header-height: 3.5rem;
  }

  body {
    font-size: var(--font-size-base);
  }

  /* Larger text for better readability */
  h1 { font-size: var(--font-size-3xl); }
  h2 { font-size: var(--font-size-2xl); }
  h3 { font-size: var(--font-size-xl); }
  h4 { font-size: var(--font-size-lg); }

  /* Ensure touch targets are at least 44x44px */
  .btn,
  .form-input,
  .form-select,
  .nav-link {
    min-height: 2.75rem;
  }

  /* Spacing adjustments */
  .container {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  /* Stack flex items on mobile */
  .flex-mobile-col {
    flex-direction: column;
  }

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

  /* Mobile navigation */
  .navbar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
  }

  .navbar-nav {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    background-color: var(--color-surface);
    border-bottom: 0.0625rem solid var(--color-border);
    flex-direction: column;
    padding: var(--space-4);
    gap: var(--space-2);
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
  }

  .navbar-nav.show {
    display: flex;
  }

  .nav-link {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
  }

  /* Cards */
  .card-body {
    padding: var(--space-4);
  }

  .card-header,
  .card-footer {
    padding: var(--space-3) var(--space-4);
  }

  /* Modal adjustments */
  .modal {
    max-height: 100vh;
    border-radius: var(--radius-lg);
    margin: 0;
  }

  .modal-backdrop {
    padding: 0;
  }

  .modal-body {
    padding: var(--space-4);
  }

  .modal-header,
  .modal-footer {
    padding: var(--space-4);
  }

  /* Tables - horizontal scroll */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 37.5rem;
  }

  /* Grid - single column on mobile */
  .grid-mobile-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  /* Hide on mobile */
  .hidden-mobile {
    display: none !important;
  }

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

  /* Form adjustments */
  .form-group {
    margin-bottom: var(--space-4);
  }

  /* Toast positioning */
  .toast-container {
    top: var(--space-2);
    right: var(--space-2);
    left: var(--space-2);
    max-width: none;
  }

  /* Menu card adjustments */
  .menu-card-info {
    padding: var(--space-3);
  }

  .menu-card-name {
    font-size: var(--font-size-base);
  }

  .menu-card-price {
    font-size: var(--font-size-lg);
  }
}

/* ========================================
   SMALL DEVICES (36rem+)
   Small phones in landscape
   ======================================== */

@media (min-width: 36rem) {
  :root {
    --container-padding: var(--space-6);
  }

  .container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }

  /* Grid - 2 columns */
  .grid-sm-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Modal sizing */
  .modal {
    max-width: var(--max-width-md);
  }

  .modal-sm {
    max-width: var(--max-width-sm);
  }

  /* Toast positioning */
  .toast-container {
    left: auto;
    right: var(--space-4);
  }
}

/* ========================================
   TABLETS (48rem+)
   Tablets and small laptops
   ======================================== */

@media (min-width: 48rem) {
  :root {
    --header-height: 4rem;
  }

  /* Typography scale up */
  h1 { font-size: var(--font-size-4xl); }
  h2 { font-size: var(--font-size-3xl); }
  h3 { font-size: var(--font-size-2xl); }

  /* Show desktop navigation */
  .navbar-toggle {
    display: none;
  }

  .navbar-nav {
    display: flex;
    position: static;
    flex-direction: row;
    background-color: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    max-height: none;
  }

  .nav-link {
    width: auto;
  }

  /* Grid layouts */
  .grid-md-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  /* Flex utilities */
  .flex-md-row {
    flex-direction: row;
  }

  .flex-md-col {
    flex-direction: column;
  }

  /* Card grid */
  .card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6);
  }

  /* Modal sizing */
  .modal-lg {
    max-width: var(--max-width-2xl);
  }

  /* Table - normal display */
  .table {
    min-width: auto;
  }

  /* Form layouts */
  .form-inline {
    display: flex;
    gap: var(--space-3);
    align-items: flex-end;
  }

  .form-inline .form-group {
    flex: 1;
    margin-bottom: 0;
  }

  /* Hide on tablet+ */
  .hidden-md {
    display: none !important;
  }

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

  /* Sidebar layouts */
  .layout-sidebar {
    display: grid;
    grid-template-columns: 15.625rem 1fr;
    gap: var(--space-6);
    min-height: calc(100vh - var(--header-height));
  }

  .sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
    height: fit-content;
  }

  /* Two column forms */
  .form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

  .form-row .form-group {
    margin-bottom: 0;
  }
}

/* ========================================
   DESKTOP (64rem+)
   Desktop screens
   ======================================== */

@media (min-width: 64rem) {
  :root {
    --container-padding: var(--space-8);
  }

  .container {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }

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

  /* Grid layouts */
  .grid-lg-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  /* Card grid - 3 columns */
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-8);
  }

  /* Wider sidebar */
  .layout-sidebar {
    grid-template-columns: 17.5rem 1fr;
    gap: var(--space-8);
  }

  /* Modal extra large */
  .modal-xl {
    max-width: var(--max-width-4xl);
  }

  /* Dashboard grid */
  .dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--space-6);
  }

  .dashboard-col-3 {
    grid-column: span 3;
  }

  .dashboard-col-4 {
    grid-column: span 4;
  }

  .dashboard-col-6 {
    grid-column: span 6;
  }

  .dashboard-col-8 {
    grid-column: span 8;
  }

  .dashboard-col-9 {
    grid-column: span 9;
  }

  .dashboard-col-12 {
    grid-column: span 12;
  }

  /* Hide on desktop */
  .hidden-lg {
    display: none !important;
  }

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

  /* Hover effects enabled */
  .card-hover-lg:hover {
    transform: translateY(-0.25rem);
    box-shadow: var(--shadow-xl);
  }

  /* Dropdown positioning improvements */
  .dropdown-menu {
    min-width: 13.75rem;
  }

  /* Three column forms */
  .form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
  }
}

/* ========================================
   LARGE DESKTOP (80rem+)
   Large desktop screens
   ======================================== */

@media (min-width: 80rem) {
  /* Card grid - 4 columns */
  .card-grid-xl {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  /* Grid layouts */
  .grid-xl-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .grid-xl-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  /* Hide on large desktop */
  .hidden-xl {
    display: none !important;
  }

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

  /* Wider containers for ultra-wide screens */
  .container-fluid {
    max-width: var(--max-width-7xl);
  }
}

/* ========================================
   LANDSCAPE ORIENTATION
   ======================================== */

@media (max-height: 37.5rem) and (orientation: landscape) {
  /* Reduce vertical spacing in landscape */
  .modal {
    max-height: 100vh;
    margin: 0;
  }

  .modal-body {
    padding: var(--space-3);
  }

  /* Compact header */
  :root {
    --header-height: 3rem;
  }

  /* Reduce spacing */
  .py-8 {
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
  }

  .my-8 {
    margin-top: var(--space-4);
    margin-bottom: var(--space-4);
  }
}

/* ========================================
   HIGH RESOLUTION DISPLAYS
   ======================================== */

@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
  /* Thinner borders for retina displays */
  .card,
  .form-input,
  .btn-outline {
    border-width: 0.0312rem;
  }
}

/* ========================================
   PRINT STYLES (Enhanced)
   ======================================== */

@media print {
  /* Hide navigation and interactive elements */
  .navbar,
  .navbar-toggle,
  .btn,
  .modal-backdrop,
  .toast-container,
  .dropdown-menu,
  .pagination {
    display: none !important;
  }

  /* Optimize for print */
  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  /* Page breaks */
  .card,
  .list-group-item {
    page-break-inside: avoid;
  }

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

  /* Remove shadows and backgrounds */
  .card,
  .modal {
    box-shadow: none !important;
    border: 0.0625rem solid #000 !important;
  }
}

/* ========================================
   DARK MODE ADJUSTMENTS (Optional future enhancement)
   ======================================== */

@media (prefers-color-scheme: light) {
  /* If user prefers light mode, variables could be overridden here */
  /* Currently, dark mode is the default as per requirements */
}

/* ========================================
   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;
  }

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

/* ========================================
   CUSTOM BREAKPOINT UTILITIES
   ======================================== */

/* Container queries support (progressive enhancement) */
@supports (container-type: inline-size) {
  .container-query {
    container-type: inline-size;
  }

  @container (min-width: 25rem) {
    .cq-grid-2 {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @container (min-width: 37.5rem) {
    .cq-grid-3 {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
  }
}

/* ========================================
   FOCUS STYLES FOR KEYBOARD NAVIGATION
   ======================================== */

@media (hover: none) {
  /* Touch devices - remove hover states */
  .card-hover:hover,
  .btn:hover,
  .nav-link:hover {
    transform: none;
  }
}

/* Enhanced focus for keyboard users */
body:not(.user-is-tabbing) *:focus {
  outline: none;
}

body.user-is-tabbing *:focus {
  outline: 0.125rem solid var(--color-border-focus);
  outline-offset: 0.125rem;
}

/* ========================================
   UTILITY RESPONSIVE CLASSES
   ======================================== */

/* Display utilities per breakpoint */
@media (max-width: 47.9375rem) {
  .d-mobile-none { display: none !important; }
  .d-mobile-block { display: block !important; }
  .d-mobile-flex { display: flex !important; }
  .d-mobile-grid { display: grid !important; }
}

@media (min-width: 48rem) {
  .d-md-none { display: none !important; }
  .d-md-block { display: block !important; }
  .d-md-flex { display: flex !important; }
  .d-md-grid { display: grid !important; }
}

@media (min-width: 64rem) {
  .d-lg-none { display: none !important; }
  .d-lg-block { display: block !important; }
  .d-lg-flex { display: flex !important; }
  .d-lg-grid { display: grid !important; }
}

/* Text alignment per breakpoint */
@media (min-width: 48rem) {
  .text-md-left { text-align: left !important; }
  .text-md-center { text-align: center !important; }
  .text-md-right { text-align: right !important; }
}

@media (min-width: 64rem) {
  .text-lg-left { text-align: left !important; }
  .text-lg-center { text-align: center !important; }
  .text-lg-right { text-align: right !important; }
}

/* Spacing adjustments per breakpoint */
@media (min-width: 48rem) {
  .mt-md-0 { margin-top: 0 !important; }
  .mt-md-4 { margin-top: var(--space-4) !important; }
  .mt-md-8 { margin-top: var(--space-8) !important; }

  .mb-md-0 { margin-bottom: 0 !important; }
  .mb-md-4 { margin-bottom: var(--space-4) !important; }
  .mb-md-8 { margin-bottom: var(--space-8) !important; }

  .py-md-8 {
    padding-top: var(--space-8) !important;
    padding-bottom: var(--space-8) !important;
  }

  .px-md-8 {
    padding-left: var(--space-8) !important;
    padding-right: var(--space-8) !important;
  }
}

@media (min-width: 64rem) {
  .mt-lg-0 { margin-top: 0 !important; }
  .mt-lg-8 { margin-top: var(--space-8) !important; }
  .mt-lg-12 { margin-top: var(--space-12) !important; }

  .mb-lg-0 { margin-bottom: 0 !important; }
  .mb-lg-8 { margin-bottom: var(--space-8) !important; }
  .mb-lg-12 { margin-bottom: var(--space-12) !important; }
}
