/* Responsive Design Enhancements for All Pages */

/* ========================================
   TABLE RESPONSIVENESS
   ======================================== */

/* Large tablets and below */
@media (max-width: 992px) {
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
  }

  .table {
    min-width: 800px;
  }

  /* Better table scrolling indicator */
  .table-container::after {
    content: "→ Scroll for more";
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: #6c757d;
    padding: 0.5rem 0;
    font-style: italic;
  }
}

/* Tablets */
@media (max-width: 768px) {
  /* Page headers */
  .subjects-header h1,
  .venues-header h1,
  .departments-header h1,
  .users-header h1 {
    font-size: 1.5rem !important;
  }

  /* Table improvements */
  .table {
    font-size: 0.875rem;
  }

  .table thead th {
    font-size: 0.8rem;
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
  }

  .table tbody td {
    font-size: 0.875rem;
    padding: 0.75rem 0.5rem;
  }

  /* Touch-friendly buttons */
  .btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
  }

  .btn-sm {
    min-height: 38px;
    font-size: 0.875rem;
  }

  /* Download buttons stack */
  .download-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-download {
    width: 100%;
    margin: 0;
  }

  /* Form improvements */
  .form-select,
  .form-control,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
  }

  /* Filter sections */
  .filter-section {
    padding: 1.5rem 1rem;
  }

  .form-section {
    padding: 1.5rem 1rem;
  }

  /* Modal improvements */
  .modal-dialog {
    margin: 1rem;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-body {
    padding: 1.5rem 1rem;
  }

  .modal-footer {
    padding: 1rem;
  }

  /* Action buttons */
  .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .action-buttons .btn {
    flex: 1;
    min-width: 80px;
  }
}

/* Mobile devices */
@media (max-width: 576px) {
  /* Page headers */
  .subjects-header h1,
  .venues-header h1,
  .departments-header h1,
  .users-header h1 {
    font-size: 1.25rem !important;
  }

  .subjects-header,
  .venues-header,
  .departments-header,
  .users-header {
    padding: 1rem 0.5rem;
  }

  /* Compact tables */
  .table {
    min-width: 600px;
    font-size: 0.75rem;
  }

  .table thead th {
    font-size: 0.7rem;
    padding: 0.5rem 0.25rem;
  }

  .table tbody td {
    font-size: 0.75rem;
    padding: 0.5rem 0.25rem;
  }

  /* Filter and form sections */
  .filter-section,
  .form-section {
    padding: 1rem 0.75rem;
  }

  .filter-section h2,
  .filter-section h3,
  .form-section h2,
  .form-section h3 {
    font-size: 1.25rem;
  }

  /* Full-width form columns on mobile */
  .row > [class*="col-"] {
    margin-bottom: 1rem;
  }

  /* Buttons */
  .btn {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }

  .fixed-size-btn {
    min-width: 60px;
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
  }

  /* Modal adjustments */
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  .modal-header h5,
  .modal-title {
    font-size: 1.1rem;
  }

  .modal-body {
    padding: 1rem 0.75rem;
  }

  /* Select2 in modals */
  .select2-container {
    font-size: 0.875rem;
  }

  .select2-container--bootstrap-5 .select2-selection {
    min-height: 44px;
  }

  /* Success alerts */
  #successAlert {
    min-width: 250px;
    right: 10px;
    left: 10px;
    top: 70px;
  }

  /* Badges */
  .badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
  }

  /* Info blocks (for venues slot guide) */
  .info-block {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .info-block .slot {
    font-size: 0.875rem;
  }

  /* Empty states */
  .empty-state {
    padding: 2rem 1rem;
  }

  .empty-state i {
    font-size: 3rem;
  }

  .empty-state p {
    font-size: 1rem;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  /* Headers */
  .subjects-header h1,
  .venues-header h1,
  .departments-header h1,
  .users-header h1 {
    font-size: 1.1rem !important;
  }

  /* Container padding */
  .container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  /* Very compact tables */
  .table {
    min-width: 500px;
    font-size: 0.7rem;
  }

  .table thead th,
  .table tbody td {
    padding: 0.4rem 0.2rem;
  }

  /* Download buttons */
  .btn-download {
    font-size: 0.8rem;
    padding: 0.5rem;
  }

  /* Forms */
  .form-label {
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
  }

  /* Modals */
  .modal-dialog {
    margin: 0.25rem;
    max-width: calc(100% - 0.5rem);
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 0.75rem;
  }

  /* Action buttons stack completely */
  .action-buttons {
    flex-direction: column;
  }

  .action-buttons .btn {
    width: 100%;
  }
}

/* Extra small devices (very small phones) */
@media (max-width: 360px) {
  /* Headers */
  .subjects-header h1,
  .venues-header h1,
  .departments-header h1,
  .users-header h1 {
    font-size: 1rem !important;
  }

  /* Sections */
  .filter-section,
  .form-section {
    padding: 0.75rem 0.5rem;
  }

  /* Tables */
  .table {
    min-width: 450px;
    font-size: 0.65rem;
  }

  /* Buttons */
  .btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
    min-height: 40px;
  }

  .btn-sm {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
    min-height: 36px;
  }

  /* Modals */
  .modal-dialog {
    margin: 0.25rem;
  }

  .modal-header h5 {
    font-size: 0.95rem;
  }

  /* Form elements */
  .form-select,
  .form-control {
    min-height: 44px;
    font-size: 14px;
    padding: 0.5rem;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  /* Hide non-printable elements */
  .sidebar,
  .mobile-toggle,
  .sidebar-overlay,
  .filter-section,
  .download-section,
  .btn-download,
  .action-buttons,
  .form-section,
  #successAlert,
  .modal,
  .modal-backdrop {
    display: none !important;
  }

  /* Adjust layout for print */
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  /* Table improvements */
  .table {
    font-size: 10pt;
    border-collapse: collapse !important;
  }

  .table thead th {
    background-color: #343a40 !important;
    color: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .table tbody tr {
    page-break-inside: avoid;
  }

  /* Remove shadows and gradients */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* Page breaks */
  h1, h2, h3 {
    page-break-after: avoid;
  }

  /* Ensure links show URLs */
  a[href]:after {
    content: none !important;
  }
}

/* ========================================
   LANDSCAPE ORIENTATION
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
  /* Optimize for landscape mobile */
  .table-container {
    max-height: 60vh;
    overflow-y: auto;
  }

  .modal-dialog {
    max-height: 90vh;
    overflow-y: auto;
  }

  .filter-section,
  .form-section {
    padding: 1rem;
  }

  /* Compact spacing in landscape */
  .mb-3 {
    margin-bottom: 0.75rem !important;
  }
}

/* ========================================
   HIGH DPI / RETINA DISPLAYS
   ======================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Crisper borders on retina displays */
  .table,
  .table th,
  .table td {
    border-width: 0.5px;
  }

  /* Better icon rendering */
  .fa, .fas, .far, .fal, .fab {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus indicators for keyboard navigation */
@media (prefers-reduced-motion: no-preference) {
  *:focus {
    outline: 2px solid #2575fc;
    outline-offset: 2px;
  }
}

/* Respect user's motion preferences */
@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 support */
@media (prefers-contrast: high) {
  .btn {
    border-width: 2px;
  }

  .table th,
  .table td {
    border-width: 2px;
  }
}
