/* Mobile Responsiveness Fixes for OptimotiveUpdater Web App */

/* Override site.css mobile sidebar styles */
@media (max-width: 768px) {
  /* First, override the default mobile sidebar from site.css */
  .sidebar,
  .sidebar.collapsed,
  .sidebar:not(.collapsed) {
    width: 250px !important;
    left: -250px !important;
  }
  
  /* Main content should take full width on mobile */
  .main-content,
  .main-content.expanded {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 15px !important;
  }
}

/* Base Mobile Adjustments */
@media (max-width: 768px) {
  /* Increase base font size for better readability */
  html {
    font-size: 16px;
  }
  
  body {
    font-size: 16px;
    line-height: 1.6;
  }
  
  /* Fix header for mobile */
  .top-header {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .header-logo {
    max-height: 35px !important;
    max-width: 180px !important;
  }
  
  /* Increase touch targets */
  button, 
  .btn, 
  a.btn,
  .hero-button,
  .sidebar-nav a,
  .user-menu-toggle {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
    font-size: 16px;
  }
  
  /* Square buttons specific fix */
  .square-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
  }
  
  /* Fix sidebar for mobile - completely hidden by default */
  .sidebar {
    position: fixed !important;
    top: 60px !important;
    left: -250px !important; /* Start completely off-screen */
    width: 250px !important;
    height: calc(100vh - 60px) !important;
    z-index: 1001 !important;
    transition: left 0.3s ease !important;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2) !important;
    /* Override the icon-only state on mobile */
    overflow-y: auto !important;
  }
  
  /* When active, slide in from left */
  .sidebar.active {
    left: 0 !important;
  }
  
  /* Hide the collapsed state on mobile */
  .sidebar.collapsed {
    left: -250px !important;
    width: 250px !important;
  }
  
  /* Ensure sidebar content is always visible when active */
  .sidebar.active .sidebar-nav span {
    display: inline !important;
    opacity: 1 !important;
  }
  
  /* Fix hamburger menu position */
  .sidebar-toggle {
    position: fixed !important;
    top: 70px !important;
    left: 10px !important;
    z-index: 1002 !important;
    background: var(--card-background) !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  }
  
  .hamburger-menu {
    background: var(--button-solid) !important;
    color: white !important;
    border: none !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
  }
  
  /* Sidebar overlay */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
  }
  
  .sidebar-overlay.active {
    display: block;
  }
  
  /* Main content adjustments */
  .main-content {
    margin-left: 0 !important;
    padding: 15px;
    width: 100%;
  }
  
  /* Card and container fixes */
  .card {
    margin-bottom: 20px;
    border-radius: 8px;
  }
  
  .card-body {
    padding: 15px;
  }
  
  /* Table responsiveness */
  .table-responsive {
    border: none;
    margin: 0 -15px;
  }
  
  table {
    font-size: 14px;
  }
  
  /* Form adjustments */
  .form-control,
  .form-select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
    min-height: 44px;
  }
  
  /* Hero section mobile optimization */
  .home-hero {
    padding: 30px 15px;
  }
  
  .hero-container {
    flex-direction: column;
    text-align: center;
  }
  
  .hero-image-wrapper {
    max-width: 250px;
    margin: 0 auto 20px;
  }
  
  .hero-title {
    font-size: 28px;
    margin-bottom: 15px;
  }
  
  .hero-subtitle {
    font-size: 16px;
    margin-bottom: 20px;
  }
  
  .hero-buttons {
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }
  
  .hero-button {
    width: 100%;
    text-align: center;
    padding: 14px 20px;
    font-size: 16px;
  }
  
  /* Features section mobile */
  .features-section {
    padding: 30px 15px;
  }
  
  .features-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .feature-card {
    padding: 20px;
    text-align: center;
  }
  
  .feature-title {
    font-size: 20px;
  }
  
  .feature-description {
    font-size: 15px;
    line-height: 1.6;
    /* Remove text truncation */
    display: block !important;
    -webkit-line-clamp: unset !important;
    max-height: none !important;
  }
  
  /* Footer adjustments */
  .app-footer {
    padding: 15px;
    position: relative;
  }
  
  .footer-content {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  
  .footer-left,
  .footer-right {
    width: 100%;
  }
  
  /* License status mobile */
  .license-status {
    font-size: 14px;
    padding: 8px 12px;
    white-space: normal;
  }
  
  /* Modal adjustments */
  .modal-dialog {
    margin: 10px;
    max-width: calc(100% - 20px);
  }
  
  .modal-content {
    border-radius: 8px;
  }
  
  /* Dashboard grid mobile */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  /* Alert messages */
  .alert {
    margin: 10px 0;
    padding: 12px;
    font-size: 15px;
  }
  
  /* Pagination mobile */
  .pagination {
    flex-wrap: wrap;
    gap: 5px;
  }
  
  .page-link {
    padding: 10px 15px;
    font-size: 14px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Breadcrumb mobile */
  .breadcrumb {
    font-size: 14px;
    padding: 10px 0;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  /* Data tables mobile */
  .data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* File upload area mobile */
  .file-upload-area {
    padding: 30px 20px;
    font-size: 15px;
  }
  
  /* User menu dropdown mobile */
  .user-dropdown {
    right: 10px;
    min-width: 200px;
  }
  
  /* Badge adjustments */
  .badge {
    font-size: 12px;
    padding: 4px 8px;
  }
  
  /* License alert mobile */
  .license-alert {
    margin: 20px 10px;
    padding: 30px 20px;
    min-height: auto;
  }
  
  .license-alert h3 {
    font-size: 24px;
  }
  
  .license-alert p {
    font-size: 16px;
  }
  
  .license-alert .icon {
    font-size: 48px;
  }
}

/* Small mobile devices (iPhone SE, etc.) */
@media (max-width: 375px) {
  .hero-title {
    font-size: 24px;
  }
  
  .feature-title {
    font-size: 18px;
  }
  
  .btn {
    font-size: 14px;
    padding: 10px 14px;
  }
  
  .header-logo {
    max-width: 150px !important;
  }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar {
    top: 50px;
    height: calc(100vh - 50px);
  }
  
  .top-header {
    padding: 6px 12px;
  }
  
  .hero-container {
    flex-direction: row;
  }
  
  .hero-image-wrapper {
    max-width: 200px;
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Prevent zoom on input focus */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px !important;
  }
  
  /* Fix position fixed issues */
  .sidebar {
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateZ(0);
  }
}

/* Accessibility improvements for mobile */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
  /* Add dark mode styles here if needed */
}

/* Print styles for mobile */
@media print {
  .sidebar,
  .hamburger-menu,
  .user-menu,
  .app-footer {
    display: none !important;
  }
  
  .main-content {
    margin: 0 !important;
  }
}