/* Mobile Responsive Enhancements */
/* Comprehensive mobile support for all views */

/* ===============================================
   MOBILE BREAKPOINTS
   =============================================== */

/* Mobile devices (portrait phones, less than 768px) */
@media (max-width: 767px) {
  
  /* ===============================================
     GLOBAL LAYOUT
     =============================================== */
  
  .container {
    padding: 12px;
  }

  /* Header adjustments */
  header {
    padding: 16px;
    margin-bottom: 16px;
  }

  h1 {
    font-size: 20px;
    margin-bottom: 4px;
  }

  .subtitle {
    font-size: 13px;
  }

  /* ===============================================
     NAVIGATION TABS
     =============================================== */
  
  .tabs {
    flex-direction: column;
    gap: 2px;
    padding: 2px;
  }

  .tab {
    width: 100%;
    text-align: center;
    padding: 10px 16px;
    font-size: 13px;
  }

  /* Horizontal scroll for many tabs */
  .tabs.horizontal-scroll {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }

  .tabs.horizontal-scroll .tab {
    flex: 0 0 auto;
    min-width: 100px;
    scroll-snap-align: start;
  }

  /* ===============================================
     CARDS & CONTENT
     =============================================== */
  
  .card {
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 8px;
  }

  .card-header {
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  /* ===============================================
     FORMS - FULL RESPONSIVE
     =============================================== */
  
  .form-section {
    margin-bottom: 24px;
  }

  .section-title {
    font-size: 13px;
    margin-bottom: 12px;
  }

  /* Stack form rows vertically */
  .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 12px;
  }

  .form-group {
    margin-bottom: 0;
  }

  .form-label {
    font-size: 13px;
    margin-bottom: 6px;
  }

  /* Touch-friendly form controls */
  .form-control,
  select,
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  textarea {
    height: 44px !important; /* iOS minimum touch target */
    font-size: 16px !important; /* Prevent iOS zoom on focus */
    padding: 0 12px !important;
    border-radius: 8px;
  }

  textarea.form-control {
    height: 100px !important;
    padding: 12px !important;
  }

  /* Buttons - touch friendly */
  button,
  .btn,
  .button {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 15px;
    border-radius: 8px;
    width: 100%;
    margin-bottom: 8px;
  }

  /* Button groups stack vertically */
  .button-group,
  .form-actions,
  .modal-actions {
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    margin-top: 16px;
  }

  .button-group button,
  .form-actions button,
  .modal-actions button {
    width: 100%;
  }

  /* Primary button on top (reverse order) */
  .button-group button:first-child {
    order: -1;
  }

  /* ===============================================
     MODALS - FULL SCREEN ON MOBILE
     =============================================== */
  
  .modal {
    padding: 0;
    align-items: flex-start;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-primary);
    padding: 16px;
    border-bottom: 1px solid var(--border);
  }

  .modal-title {
    font-size: 18px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    padding: 16px;
    border-top: 1px solid var(--border);
  }

  /* Close button */
  .close-button {
    min-width: 44px;
    min-height: 44px;
  }

  /* ===============================================
     TABLES - RESPONSIVE CARDS
     =============================================== */
  
  /* Hide table headers on mobile */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    font-size: 13px;
  }

  /* Option 1: Horizontal scroll */
  table.scroll-mobile {
    min-width: 600px;
  }

  /* Option 2: Card layout for tables */
  table.card-mobile {
    display: block;
    border: none;
  }

  table.card-mobile thead {
    display: none;
  }

  table.card-mobile tbody {
    display: block;
  }

  table.card-mobile tr {
    display: block;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
  }

  table.card-mobile td {
    display: block;
    text-align: left;
    padding: 8px 0;
    border: none;
  }

  table.card-mobile td:before {
    content: attr(data-label);
    font-weight: 600;
    display: inline-block;
    width: 40%;
    margin-right: 10px;
    color: var(--text-secondary);
  }

  /* ===============================================
     APPROVAL CARDS - OPTIMIZED
     =============================================== */
  
  .approval-card,
  .request-card {
    margin-bottom: 12px;
  }

  .approval-card-header {
    font-size: 14px;
    padding: 12px;
  }

  .approval-card-body {
    padding: 12px;
  }

  .approval-detail-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }

  .approval-detail-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
  }

  .approval-detail-value {
    font-size: 14px;
    color: var(--text-primary);
  }

  /* Status badges */
  .badge,
  .status-badge {
    font-size: 11px;
    padding: 4px 8px;
  }

  /* ===============================================
     STATS CARDS - 2 COLUMNS ON MOBILE
     =============================================== */
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 11px;
  }

  /* ===============================================
     FILTERS - COLLAPSIBLE ON MOBILE
     =============================================== */
  
  .filters-container {
    margin-bottom: 16px;
  }

  .filter-toggle {
    display: block;
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
  }

  .filters-wrapper {
    display: none;
  }

  .filters-wrapper.active {
    display: block;
  }

  .filter-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* ===============================================
     SEARCH BAR
     =============================================== */
  
  .search-container {
    margin-bottom: 12px;
  }

  .search-input {
    height: 44px;
    font-size: 16px;
    padding: 0 40px 0 16px;
  }

  /* ===============================================
     PAGINATION
     =============================================== */
  
  .pagination {
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
  }

  .pagination button {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    font-size: 14px;
  }

  /* Hide page numbers on very small screens */
  @media (max-width: 400px) {
    .pagination .page-number {
      display: none;
    }
    
    .pagination .page-number.active,
    .pagination .prev-button,
    .pagination .next-button {
      display: inline-flex;
    }
  }

  /* ===============================================
     DROPDOWNS & SELECTS
     =============================================== */
  
  select {
    height: 44px;
    font-size: 16px;
    padding: 0 32px 0 12px;
    background-position: right 12px center;
  }

  /* Custom dropdown menus */
  .dropdown-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-height: 60vh;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
  }

  /* ===============================================
     FLOATING ACTION BUTTON (FAB)
     =============================================== */
  
  .fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
  }

  .fab:active {
    transform: scale(0.95);
  }

  /* ===============================================
     ADMIN PANEL - SIDEBAR TO DRAWER
     =============================================== */
  
  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 2000;
    transition: left 0.3s;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  }

  .admin-sidebar.open {
    left: 0;
  }

  .admin-content {
    width: 100%;
    margin-left: 0;
  }

  /* Menu toggle button */
  .menu-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    z-index: 1500;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
  }

  /* Backdrop for sidebar */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  /* ===============================================
     FILE UPLOAD
     =============================================== */
  
  .file-upload-area {
    padding: 24px 16px;
  }

  .file-upload-button {
    width: 100%;
    height: 44px;
  }

  .file-list {
    margin-top: 12px;
  }

  .file-item {
    padding: 12px;
    margin-bottom: 8px;
  }

  /* ===============================================
     ALERTS & TOASTS
     =============================================== */
  
  .alert,
  .toast {
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
  }

  /* Toast notifications */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }

  .toast {
    width: 100%;
  }

  /* ===============================================
     LOADING INDICATORS
     =============================================== */
  
  .loading-overlay {
    padding: 20px;
  }

  .spinner {
    width: 40px;
    height: 40px;
  }

  .loading-text {
    font-size: 14px;
    margin-top: 12px;
  }

  /* ===============================================
     UTILITY CLASSES
     =============================================== */
  
  /* Hide on mobile */
  .hide-mobile {
    display: none !important;
  }

  /* Show only on mobile */
  .show-mobile {
    display: block !important;
  }

  /* Text alignment */
  .text-center-mobile {
    text-align: center !important;
  }

  /* Full width on mobile */
  .full-width-mobile {
    width: 100% !important;
  }

  /* Spacing utilities */
  .mb-mobile-16 {
    margin-bottom: 16px !important;
  }

  .p-mobile-12 {
    padding: 12px !important;
  }
}

/* ===============================================
   TABLET BREAKPOINT (768px - 1024px)
   =============================================== */

@media (min-width: 768px) and (max-width: 1024px) {
  
  .container {
    padding: 20px;
  }

  /* 2 columns for most grids */
  .form-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Modals slightly smaller */
  .modal-content {
    max-width: 90%;
  }
}

/* ===============================================
   LANDSCAPE MOBILE (max-height: 500px)
   =============================================== */

@media (max-height: 500px) and (orientation: landscape) {
  
  /* Reduce vertical spacing */
  header {
    padding: 12px;
    margin-bottom: 12px;
  }

  .card {
    padding: 12px;
    margin-bottom: 12px;
  }

  .form-section {
    margin-bottom: 16px;
  }

  /* Modals scroll */
  .modal-content {
    height: 100vh;
    overflow-y: auto;
  }
}
