/* =============================================================================
   RESPONSIVE STYLES - Mobile-First Responsive Design
   ============================================================================= */

/* Mobile-First Base Styles (320px+) - Default styles are mobile-optimized */

/* CRITICAL: Mobile Viewport and Overflow Control */
@media (max-width: 767px) {
  /* Force viewport constraints */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  /* Container and layout constraints */
  .container, 
  .admin-panel,
  .form-section {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  /* AGGRESSIVE: Force select elements to use custom styling */
  select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5568' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 12px !important;
    max-width: calc(100vw - 60px) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-size: 16px !important; /* Prevent zoom on iOS */
    padding: 10px 30px 10px 12px !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 6px !important;
    background-color: white !important;
  }

  /* Force select options to be constrained */
  select option {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
  }

  /* Mobile Safari specific fixes */
  @supports (-webkit-touch-callout: none) {
    select {
      font-size: 16px !important; /* Prevent zoom */
    }
  }

  /* Additional mobile browser fixes */
  select:focus {
    outline: none !important;
    border-color: #667eea !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
  }
}

/* Enhanced Mobile Styles (320px - 767px) */
@media (max-width: 767px) {
  /* Body and Layout Adjustments */
  body {
    padding: 10px;
  }

  /* Container Responsive */
  .container, 
  .admin-panel {
    padding: 20px;
    margin: 0 auto;
    border-radius: 12px;
  }

  /* Header Mobile Optimization */
  .header {
    flex-direction: row; /* Keep horizontal layout */
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px; /* Reduced padding for mobile */
    gap: 10px; /* Reduced gap */
  }

  /* Logo Mobile Responsive - Keep full logo */
  .logo {
    font-size: 18px; /* Smaller logo for mobile */
    justify-content: flex-start;
    flex-shrink: 0; /* Prevent logo from shrinking */
  }

  /* User Info Mobile Layout - Hide text, keep avatar and image */
  .user-info {
    gap: 8px;
    justify-content: center;
    flex: 1; /* Take available space */
    min-width: 0; /* Allow shrinking */
  }

  /* Hide only user details text on mobile, keep avatar */
  .user-details {
    display: none;
  }

  /* Keep avatar visible and make it smaller on mobile */
  .user-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  /* Hamburger menu positioning */
  .mobile-menu-toggle {
    flex-shrink: 0; /* Prevent hamburger from shrinking */
    margin-left: auto; /* Push to right */
  }

  .user-avatar {
    width: 32px;
    height: 32px;
  }

  .user-name {
    font-size: 14px;
  }

  .user-email {
    font-size: 11px;
  }

  /* Header Actions Mobile - Now handled by hamburger menu */
  /* Styles moved to layout.css for hamburger menu implementation */

  .admin-badge {
    padding: 4px 8px;
    font-size: 11px;
  }

  .admin-toggle,
  .logout-btn {
    padding: 8px 16px;
    font-size: 12px;
  }

  /* Typography Mobile */
  h2 {
    font-size: 20px;
    text-align: center;
    margin-bottom: 20px;
  }

  /* Form Section Mobile - AGGRESSIVE Constraints */
  .form-section {
    padding: 12px !important;
    margin: 10px 5px !important;
    width: calc(100% - 10px) !important;
    max-width: calc(100vw - 20px) !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .row {
    margin-bottom: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  /* FORCE all form elements to respect boundaries */
  .row > * {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Form Elements Mobile - AGGRESSIVE Overflow Prevention */
  select,
  .branch-search-input {
    padding: 10px 35px 10px 12px !important;
    font-size: 14px !important;
    width: 100% !important;
    max-width: calc(100vw - 60px) !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    border-radius: 6px !important;
  }

  /* FORCE select dropdown to stay in bounds */
  select {
    appearance: none !important;
    background-size: 12px !important;
    background-position: right 8px center !important;
    padding-right: 30px !important;
  }

  /* Select options - prevent overflow */
  select option {
    padding: 6px 8px !important;
    font-size: 14px !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    word-break: break-all !important;
  }

  /* Ensure labels don't cause overflow */
  .row label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #4a5568;
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Container width control */
  .container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  /* Button Groups Mobile */
  .button-group {
    flex-direction: column;
    gap: 10px;
  }

  button {
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
    box-sizing: border-box;
  }

  /* Branch Selector Mobile - FORCE Constraints */
  .branch-selector-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    position: relative !important;
  }

  .searchable-select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    position: relative !important;
  }

  /* Search Dropdown - AGGRESSIVE Mobile Constraints */
  .search-dropdown {
    width: 100% !important;
    max-width: calc(100vw - 40px) !important;
    box-sizing: border-box !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 180px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 1000 !important;
    position: absolute !important;
    background: white !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    margin-top: 2px !important;
  }

  /* Viewport-specific dropdown constraints - ULTRA AGGRESSIVE */
  @media (max-width: 480px) {
    /* FORCE everything to fit in viewport */
    * {
      max-width: 100vw !important;
      box-sizing: border-box !important;
    }
    
    .search-dropdown {
      max-width: calc(100vw - 20px) !important;
      left: 10px !important;
      right: 10px !important;
      width: calc(100% - 20px) !important;
    }
    
    select {
      max-width: calc(100vw - 40px) !important;
      width: calc(100% - 20px) !important;
      margin: 0 10px !important;
    }
    
    .form-section {
      margin: 5px !important;
      padding: 8px !important;
      width: calc(100% - 10px) !important;
    }
    
    .row {
      padding: 0 5px !important;
      margin-bottom: 10px !important;
    }
    
    /* Container ultra-compact */
    .container {
      padding: 10px 5px !important;
      margin: 0 !important;
      width: 100% !important;
    }
  }

  /* EMERGENCY: Force all elements to respect viewport */
  @media (max-width: 320px) {
    select, .branch-search-input, .search-dropdown {
      max-width: calc(100vw - 30px) !important;
      font-size: 12px !important;
      padding: 8px 25px 8px 8px !important;
    }
    
    .form-section {
      padding: 6px !important;
      margin: 2px !important;
    }
  }

  /* Instance Mode Radio Buttons - Mobile Responsive */
  .instance-radio-container {
    width: 100%;
    overflow-x: auto;
  }

  .radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  /* Radio Buttons Mobile */
  .radio-group {
    gap: 8px;
  }

  .radio-option {
    padding: 10px 12px;
  }

  .radio-label {
    font-size: 13px;
  }

  /* Branch Selector Mobile */
  .dropdown-option {
    padding: 10px 12px;
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Prevent long project/env names from overflowing */
  .dropdown-option[data-value] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Show full text on hover/focus for truncated items */
  .dropdown-option[data-value]:hover,
  .dropdown-option[data-value]:focus {
    white-space: normal;
    overflow: visible;
    z-index: 1001;
    position: relative;
    background-color: #f7fafc;
  }

  /* Textarea Mobile */
  textarea {
    height: 250px;
    font-size: 12px;
    padding: 12px;
  }

  /* Output Section Mobile */
  .output-label {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .output-label h3 {
    font-size: 14px;
  }

  /* URL Link Container Mobile */
  .url-link-container {
    padding: 12px;
  }

  .url-link-label {
    font-size: 12px;
  }

  .url-link {
    padding: 10px 20px;
    font-size: 14px;
  }

  /* Stats Grid Mobile */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .stat-card {
    padding: 16px;
    text-align: center;
  }

  .stat-card .value {
    font-size: 24px;
  }

  /* Admin Tabs Mobile - Dropdown Style */
  .admin-tabs {
    position: relative;
    flex-direction: column;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
  }

  /* Mobile Tab Header - MOBILE ONLY */
  .mobile-tab-header {
    display: none; /* Hidden by default */
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
  }

  .mobile-tab-header:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6b4190 100%);
  }

  .mobile-tab-arrow {
    transition: transform 0.3s ease;
    font-size: 14px;
  }

  /* Force arrow rotation based on expanded state */
  .admin-tabs.expanded .mobile-tab-arrow {
    transform: rotate(180deg);
  }

  /* Ensure arrow resets when not expanded */
  .admin-tabs:not(.expanded) .mobile-tab-arrow {
    transform: rotate(0deg);
  }

  /* FORCE hide mobile header on desktop - highest specificity */
  @media (min-width: 768px) {
    .admin-panel .admin-tabs .mobile-tab-header,
    .mobile-tab-header {
      display: none !important;
      visibility: hidden !important;
      height: 0 !important;
      overflow: hidden !important;
    }
  }

  /* Hide mobile header on desktop */
  .mobile-tab-header {
    display: none !important;
  }

  /* Show mobile header only on mobile */
  @media (max-width: 767px) {
    .mobile-tab-header {
      display: flex !important;
      visibility: visible !important;
      height: auto !important;
    }
  }

  /* Ensure admin tabs display correctly on desktop */
  @media (min-width: 768px) {
    .admin-tabs {
      display: flex !important;
      flex-direction: row !important;
      gap: 10px !important;
      background: transparent !important;
      border-radius: 0 !important;
      box-shadow: none !important;
      overflow: visible !important;
      margin-bottom: 20px;
      border-bottom: 2px solid #e2e8f0;
    }

    .admin-tab {
      display: inline-block !important;
      padding: 12px 24px !important;
      background: none !important;
      color: #718096 !important;
      border: none !important;
      border-bottom: 2px solid transparent !important;
      border-radius: 0 !important;
      text-align: center !important;
      width: auto !important;
      transition: all 0.3s ease !important;
    }

    .admin-tab.active {
      color: #667eea !important;
      border-bottom-color: #667eea !important;
      background: none !important;
    }

    .admin-tab:hover {
      color: #667eea !important;
      background: none !important;
    }
  }

  /* Hide all tabs by default on mobile except active one */
  .admin-tab {
    padding: 12px 20px;
    font-size: 14px;
    border-bottom: 1px solid #e2e8f0;
    background: white;
    color: #4a5568;
    border-radius: 0;
    text-align: left;
    width: 100%;
    transition: all 0.3s ease;
    border: none;
  }

  /* On mobile, hide all tabs by default */
  @media (max-width: 767px) {
    .admin-tab {
      display: none !important;
    }

    /* Show all tabs when dropdown is expanded */
    .admin-tabs.expanded .admin-tab {
      display: block !important;
    }
  }

  /* Always show active tab indicator */
  .admin-tab.active {
    background: #f7fafc;
    color: #667eea;
    font-weight: 600;
    border-left: 4px solid #667eea;
  }

  /* Hover effect for mobile tabs */
  .admin-tab:hover {
    background: #f7fafc;
    color: #667eea;
  }

  /* Last tab no border */
  .admin-tab:last-child {
    border-bottom: none;
  }

  /* Management Buttons Mobile - Improved Touch-Friendly */
  .mgmt-action-btn {
    padding: 12px 16px;
    font-size: 14px;
    margin: 4px;
    min-height: 44px;
    min-width: auto;
    white-space: nowrap;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }

  /* Repository Tab Button Container - Mobile Responsive */
  #repositoriesTab > div:first-child {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    align-items: stretch !important;
    margin-bottom: 20px !important;
  }

  /* Repository Tab Buttons - Mobile Optimized */
  #repositoriesTab .mgmt-action-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
    padding: 14px 12px;
    font-size: 13px;
    text-align: center;
  }

  /* Spot Scheduler Button Containers - Mobile Responsive */
  #spotSchedulerTab .mgmt-action-btn {
    padding: 12px 16px;
    font-size: 13px;
    min-height: 44px;
    margin: 2px;
  }

  /* Button Groups in Spot Scheduler - Stack on Mobile */
  #spotSchedulerTab div[style*="display: flex"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Queue Tab Buttons */
  #queueTab .mgmt-action-btn {
    width: 100%;
    padding: 14px 16px;
    font-size: 14px;
    margin: 8px 0;
  }

  /* Repository Cards Mobile Optimization */
  #repositoriesList > div > div {
    padding: 16px !important;
    margin-bottom: 16px !important;
  }

  /* Repository Card Header - Stack on Mobile */
  #repositoriesList div[style*="justify-content: between"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  /* Repository Title - Prevent Overflow */
  #repositoriesList h4 {
    font-size: 16px !important;
    line-height: 1.3 !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }

  /* Repository URL Links - Break Long URLs */
  #repositoriesList h4 a {
    word-break: break-all !important;
    overflow-wrap: break-word !important;
    display: block !important;
  }

  /* Branch Info Container - Stack Vertically */
  #repositoriesList div[style*="gap: 12px"] {
    flex-direction: column !important;
    gap: 8px !important;
    align-items: flex-start !important;
  }

  /* Branch Info Spans - Prevent Overflow */
  #repositoriesList div[style*="gap: 12px"] span {
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    max-width: 100% !important;
  }

  /* Branch Count Badges - Responsive */
  #repositoriesList span[style*="font-family: monospace"] {
    display: inline-block !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Repository Action Buttons - Full Width on Mobile */
  #repositoriesList div[style*="gap: 8px"]:last-of-type {
    width: 100% !important;
    justify-content: stretch !important;
    margin-top: 8px !important;
  }

  #repositoriesList div[style*="gap: 8px"]:last-of-type .mgmt-action-btn {
    flex: 1 !important;
    padding: 12px 8px !important;
    font-size: 12px !important;
    min-height: 44px !important;
  }

  /* Project Tags Container - Better Wrapping */
  #repositoriesList div[style*="flex-wrap: wrap"] {
    gap: 6px !important;
  }

  /* Project Tags - Responsive Sizing */
  #repositoriesList span[style*="border-radius: 20px"] {
    font-size: 11px !important;
    padding: 6px 10px !important;
    word-break: break-word !important;
    max-width: 100% !important;
  }

  /* Repository Metadata - Better Spacing */
  #repositoriesList div[style*="border-top: 1px solid"] {
    margin-top: 12px !important;
    padding-top: 12px !important;
    font-size: 11px !important;
  }

  /* Activity Logs Buttons */
  .projects-table + div .mgmt-action-btn,
  div[style*="margin-bottom: 20px"] .mgmt-action-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
    padding: 12px 8px;
    font-size: 12px;
  }

  /* GitHub Status Section - Mobile Responsive */
  #githubStatus {
    padding: 16px !important;
    margin-top: 20px !important;
  }

  #githubStatus h4 {
    font-size: 16px !important;
    margin-bottom: 12px !important;
  }

  /* Repository List Container - Prevent Horizontal Scroll */
  #repositoriesList {
    overflow-x: hidden !important;
    width: 100% !important;
  }

  #repositoriesList > div {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Individual Repository Item Buttons */
  .mgmt-action-btn[style*="padding: 6px 12px"] {
    padding: 10px 14px !important;
    font-size: 12px !important;
    min-height: 40px !important;
  }
  
  #mgmtProjects li {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
  }
  
  #mgmtProjects li button {
    margin-left: 0;
    align-self: stretch;
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 8px;
  }

  /* Management Tab Button Groups - Stack Vertically */
  #mgmtTab div[style*="display: flex"] {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: stretch !important;
  }

  #mgmtTab .mgmt-action-btn {
    width: 100% !important;
    margin: 0 !important;
    padding: 14px 16px !important;
    font-size: 14px !important;
  }

  /* Projects Table Mobile - Horizontal Scroll */
  .projects-table {
    font-size: 12px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .projects-table thead,
  .projects-table tbody,
  .projects-table th,
  .projects-table td,
  .projects-table tr {
    display: block;
  }

  .projects-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .projects-table tr {
    border: 1px solid #e2e8f0;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 8px;
    background: white;
  }

  .projects-table td {
    border: none;
    position: relative;
    padding: 8px 8px 8px 50%;
    text-align: left;
  }

  .projects-table td:before {
    content: attr(data-label) ": ";
    position: absolute;
    left: 6px;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    font-weight: 600;
    color: #4a5568;
  }

  /* Modal Mobile Optimization */
  .info-modal {
    padding: 20px;
    margin: 15px;
    width: calc(100% - 30px);
    max-height: 85vh;
  }

  .modal-title {
    font-size: 20px;
  }

  .modal-section h3 {
    font-size: 16px;
  }

  /* File Modal Mobile */
  #editFileModal .modal-content, 
  #newFileModal .modal-content { 
    min-width: 95vw; 
    width: 95vw;
    padding: 20px 15px;
    margin: 10px;
  }
  
  #editFileModal textarea, 
  #newFileModal textarea {
    min-height: 250px;
    font-size: 14px;
    padding: 12px;
  }
  
  .modal-actions {
    flex-direction: column !important;
    gap: 10px;
    width: 100%;
  }
  
  .modal-btn {
    width: 100%;
    padding: 12px 20px;
  }

  /* Status Badges Mobile */
  .status {
    font-size: 10px;
    padding: 3px 8px;
  }

  /* Loading Spinner Mobile */
  .loading-spinner {
    font-size: 12px;
    padding: 6px 10px;
  }

  /* IP Check Status Mobile */
  .ip-check-status {
    padding: 12px;
    margin: 12px 0;
  }

  .ip-check-progress {
    font-size: 12px;
    gap: 8px;
  }
}

/* Small Mobile Styles (480px and below) */
@media (max-width: 480px) {
  /* Ultra-compact mobile layout */
  body {
    padding: 5px;
  }

  .container,
  .admin-panel {
    padding: 15px;
    border-radius: 8px;
  }

  /* Header ultra-compact */
  .header {
    padding: 10px 12px;
    gap: 8px;
  }

  /* Logo ultra-compact - Keep full logo, just smaller */
  .logo {
    font-size: 14px;
  }

  /* Keep all logo parts visible */
  .logo-cargo,
  .logo-fl,
  .logo-spot,
  .logo-x {
    display: inline;
  }

  /* Remove the emoji override */
  .logo::before {
    content: none;
  }

  /* User info ultra-compact - show only avatar */
  .user-info {
    gap: 0;
    min-width: 28px;
  }

  .user-details {
    display: none;
  }

  .user-avatar {
    width: 24px;
    height: 24px;
  }

  /* Hamburger ultra-compact */
  .mobile-menu-toggle {
    width: 32px;
    height: 32px;
  }

  .hamburger-line {
    width: 18px;
    height: 2px;
  }

  /* Form sections ultra-compact */
  .form-section {
    padding: 12px;
  }

  /* Buttons ultra-compact */
  button {
    padding: 10px 16px;
    font-size: 13px;
  }

  /* Typography ultra-compact */
  h2 {
    font-size: 18px;
  }

  /* Management buttons ultra-compact - Still Touch-Friendly */
  .mgmt-action-btn {
    padding: 10px 12px;
    font-size: 12px;
    min-height: 40px;
  }

  /* Stats cards ultra-compact */
  .stat-card {
    padding: 12px;
  }

  .stat-card .value {
    font-size: 20px;
  }

  /* Modal ultra-compact */
  .info-modal {
    padding: 15px;
    margin: 10px;
    width: calc(100% - 20px);
  }

  /* Admin tabs ultra-compact */
  .admin-tab {
    padding: 6px 8px;
    font-size: 11px;
  }
}

/* Tablet Styles (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .container {
    max-width: 700px;
    padding: 30px;
  }

  .admin-panel {
    max-width: 900px;
    padding: 30px;
  }

  /* Header tablet layout */
  .header {
    flex-direction: row;
    padding: 18px 25px;
  }

  /* Logo tablet size */
  .logo {
    font-size: 30px;
  }

  /* Stats grid tablet - 2 columns */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Admin tabs tablet */
  .admin-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  /* Button groups tablet */
  .button-group {
    flex-direction: row;
  }

  button {
    flex: 1;
  }
}

/* Large Desktop Styles (1200px+) */
@media (min-width: 1200px) {
  .container {
    max-width: 1000px;
  }

  .admin-panel {
    max-width: 1400px;
  }

  /* Larger stats grid on big screens */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }

  /* Logo larger on big screens */
  .logo {
    font-size: 40px;
  }
}

/* Touch-Friendly Enhancements */
@media (pointer: coarse) {
  /* Larger touch targets for touch devices */
  button,
  .admin-tab,
  .dropdown-option,
  .radio-option,
  .mgmt-action-btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Larger form elements for touch */
  select,
  .branch-search-input,
  textarea {
    min-height: 44px;
  }

  /* Larger clickable areas */
  .url-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Landscape Orientation Adjustments */
@media (max-width: 767px) and (orientation: landscape) {
  /* Optimize for landscape mobile */
  .header {
    flex-direction: row;
    padding: 10px 15px;
  }

  .logo {
    font-size: 20px;
  }

  .user-info {
    gap: 8px;
  }

  .header-actions {
    gap: 6px;
  }

  /* Reduce vertical spacing in landscape */
  .container,
  .admin-panel {
    padding: 15px 20px;
  }

  h2 {
    margin-bottom: 15px;
  }

  .form-section {
    padding: 12px 16px;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
    padding: 0;
  }

  .header,
  .admin-toggle,
  .logout-btn,
  button,
  .mgmt-action-btn {
    display: none;
  }

  .container,
  .admin-panel {
    box-shadow: none;
    border: 1px solid #ccc;
    max-width: none;
  }

  /* Print-friendly colors */
  .stat-card {
    background: #f5f5f5 !important;
    color: black !important;
  }
}

/* High DPI / Retina Display Adjustments */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Ensure crisp rendering on high DPI displays */
  .logo {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* Sharper borders on high DPI */
  .container,
  .admin-panel,
  .form-section {
    border-width: 0.5px;
  }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark Mode Support (Future Enhancement) */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here in future */
  /* Currently maintaining light theme for consistency */
}

/* Focus Visible for Accessibility */
@media (prefers-reduced-motion: no-preference) {
  button:focus-visible,
  select:focus-visible,
  .branch-search-input:focus-visible,
  .admin-tab:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
  }
}