/* ==========================================================================
   Responsive Styles — Aviation Accounting System Dashboard

   Breakpoints:
     ≥1440px   Large desktop
     1200–1439px  Standard desktop
     ≤1199px   Small desktop / tablet landscape
     ≤991px    Tablet (off-canvas sidebar)
     ≤767px    Small tablet / large mobile
     ≤575px    Mobile
     ≤374px    Small mobile
   ========================================================================== */


/* ==========================================================================
   1. Large Desktop  (≥ 1440px)
   ========================================================================== */

@media (min-width: 1440px) {
  .page-content {
    padding: 32px 40px;
  }
}


/* ==========================================================================
   2. Standard Desktop  (1200px – 1439px)
   ========================================================================== */

@media (min-width: 1200px) and (max-width: 1439px) {
  .page-content {
    padding: 28px 32px;
  }
}


/* ==========================================================================
   3. Small Desktop / Tablet Landscape  (≤ 1199px)
   ========================================================================== */

@media (max-width: 1199px) {
  .header-search {
    max-width: 240px;
  }
}


/* ==========================================================================
   4. Tablet  (≤ 991px)
   ========================================================================== */

@media (max-width: 991px) {
  /* Sidebar → off-canvas overlay */
  .sidebar {
    position: fixed;
    inset-block-start: 0;
    inset-block-end: 0;
    inset-inline-start: 0;
    width: var(--sidebar-width) !important;
    z-index: var(--z-sidebar);
    transform: translateX(-100%);
    transition: transform 0.28s ease;
  }

  [dir="rtl"] .sidebar {
    transform: translateX(100%);
  }

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

  /* Main content fills full width */
  .main-content {
    margin-inline-start: 0 !important;
    width: 100%;
  }

  /* Header adjustments */
  .top-header {
    padding-inline: 16px;
  }

  .header-search {
    max-width: 200px;
  }

  /* Content area */
  .page-content {
    padding: 20px;
  }

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

  /* Footer */
  .app-footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    padding: 12px 20px;
  }
}


/* ==========================================================================
   5. Small Tablet / Large Mobile  (≤ 767px)
   ========================================================================== */

@media (max-width: 767px) {
  /* Page header stacks */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-actions {
    width: 100%;
  }

  /* User info hidden in header */
  .user-info {
    display: none;
  }

  /* Content */
  .page-content {
    padding: 16px;
  }

  /* Card padding reduction */
  .card-header {
    padding: 12px 16px;
  }

  .card-body {
    padding: 16px;
  }

  /* Table typography */
  .table {
    font-size: 12px;
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }

  /* Modal sizing */
  .modal {
    width: 95%;
    max-width: none;
  }

  /* Two-column grids stack to single */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 1.4fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Currency exchange grid */
  [style*="grid-template-columns: repeat(auto-fit"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Aviation quick stats grid */
  [style*="grid-template-columns: 1fr 1fr"][style*="gap: 16px"] {
    grid-template-columns: 1fr !important;
  }
}


/* ==========================================================================
   6. Mobile  (≤ 575px)
   ========================================================================== */

@media (max-width: 575px) {
  /* Content */
  .page-content {
    padding: 12px 16px;
  }

  /* Header */
  .top-header {
    padding-inline: 12px;
    gap: 8px;
  }

  /* Header search hidden */
  .header-search {
    display: none;
  }

  /* Quick actions hidden */
  .quick-actions-dropdown {
    display: none;
  }

  /* Page title */
  .page-title {
    font-size: 18px;
  }

  /* Cards */
  .card-header {
    padding: 12px 14px;
  }

  .card-body {
    padding: 14px;
  }

  .card-title {
    font-size: 14px;
  }

  /* KPI values */
  .kpi-value {
    font-size: 22px;
  }

  /* Tables */
  .table {
    font-size: 12px;
  }

  .table th,
  .table td {
    padding: 8px 10px;
    white-space: nowrap;
  }

  /* Mobile-friendly buttons */
  .btn {
    min-height: 38px;
    padding: 8px 16px;
    font-size: 13px;
  }

  .btn-sm {
    min-height: 32px;
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Footer */
  .app-footer {
    text-align: center;
    padding: 10px 16px;
  }

  /* Pagination */
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }

  .page-item {
    min-width: 32px;
    text-align: center;
  }

  /* Two-column grids all stack */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 1.4fr 1fr"],
  [style*="grid-template-columns: repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
  }

  /* Currency exchange grid to 1 column */
  [style*="grid-template-columns: repeat(auto-fit"][style*="minmax(180px"] {
    grid-template-columns: 1fr !important;
  }
}


/* ==========================================================================
   7. Small Mobile  (≤ 374px)
   ========================================================================== */

@media (max-width: 374px) {
  .kpi-value {
    font-size: 20px;
  }

  .kpi-label {
    font-size: 11px;
  }

  /* Content */
  .page-content {
    padding: 10px 12px;
  }

  /* Header — minimal */
  .top-header {
    padding-inline: 10px;
    gap: 6px;
  }

  /* Cards */
  .card-header {
    padding: 10px 12px;
  }

  .card-body {
    padding: 10px 12px;
  }

  .card-title {
    font-size: 13px;
  }

  /* Tables — very compact */
  .table {
    font-size: 11px;
  }

  .table th,
  .table td {
    padding: 6px 8px;
  }

  /* Buttons */
  .btn {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
  }

  .btn-sm {
    min-height: 28px;
    padding: 4px 10px;
    font-size: 12px;
  }

  /* Badge */
  .badge {
    font-size: 10px;
    padding: 2px 6px;
  }
}


/* ==========================================================================
   8. RTL Support
   ========================================================================== */

[dir="rtl"] .sidebar {
  transform: translateX(100%);
}

[dir="rtl"] .sidebar.mobile-open {
  transform: translateX(0);
}

/* Ensure overlay still covers full screen in RTL */
[dir="rtl"] .sidebar-overlay.overlay-visible {
  inset: 0;
}

/* Flip table sort icons */
[dir="rtl"] .sort-icon {
  transform: scaleX(-1);
}


/* ==========================================================================
   9. Print Styles
   ========================================================================== */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  .sidebar,
  .sidebar-overlay,
  .top-header,
  .sidebar-toggle,
  .btn,
  .pagination,
  .modal-overlay,
  .toast-container,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  .page-content {
    padding: 0 !important;
  }

  .table {
    font-size: 11px;
    min-width: 100%;
  }

  .table th,
  .table td {
    padding: 6px 8px;
  }

  .table thead {
    background-color: #f3f4f6 !important;
  }

  .table-container {
    overflow: visible !important;
  }

  /* Ensure borders are visible for print */
  .table,
  .table th,
  .table td {
    border: 1px solid #d1d5db !important;
  }

  .card {
    border: 1px solid #d1d5db !important;
    border-radius: 0 !important;
    page-break-inside: avoid;
  }

  .app-footer {
    border-top: 1px solid #d1d5db;
    padding-top: 8px;
    margin-top: 16px;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 10px;
    font-weight: normal;
  }

  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  @page {
    margin: 1.5cm;
  }
}


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

  .sidebar {
    transition: none !important;
  }

  .sidebar-overlay {
    transition: none !important;
  }

  .dropdown-menu {
    transition: none !important;
  }

  .modal {
    transition: none !important;
  }

  .toast {
    transition: none !important;
  }
}


/* ==========================================================================
   11. Dark Mode Preparation
   ========================================================================== */

/*
   Dark mode overrides should be layered on top of these responsive rules.

   When ready, wrap dark-mode overrides in:

     @media (prefers-color-scheme: dark) {
       :root {
         --background: #0f172a;
         --surface: #1e293b;
         --border: #334155;
         --text-primary: #f1f5f9;
         --text-secondary: #94a3b8;
       }

       .sidebar { background: #1e293b; }
       .top-header { background: #1e293b; border-color: #334155; }
       .card { background: #1e293b; border-color: #334155; }
       .table { color: #f1f5f9; }
       .table thead { background: #334155; }

       .sidebar-overlay.overlay-visible {
         background: rgba(0, 0, 0, 0.65);
       }

       .btn-primary {
         background: #3b82f6;
         color: #fff;
       }
     }
*/
