/* Mobile / Slide-out Menu Styles
   Applied to all screen sizes as requested.
   Includes hamburger toggle, drawer, backdrop, and animations.
   
   Enhanced for Staten Academy Improvement Plan:
   - Improved touch targets (minimum 44x44px)
   - Better mobile navigation
   - Optimized forms for mobile input
   - Enhanced calendar views for mobile
*/

/* Global Mobile Optimizations */
@media (max-width: 768px) {
    /* Ensure all interactive elements are touch-friendly */
    button, a.btn, .btn-primary, .btn-outline, .btn-secondary,
    input[type="submit"], input[type="button"], 
    .time-slot, .course-card, .teacher-card {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }
    
    /* Improve form inputs for mobile */
    input[type="text"], input[type="email"], input[type="password"],
    input[type="date"], input[type="time"], input[type="number"],
    textarea, select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
        min-height: 44px;
    }
    
    /* Better spacing for mobile */
    .card {
        padding: 20px 15px;
        margin-bottom: 15px;
    }
    
    /* Grid adjustments for mobile */
    .courses-grid, .teachers-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Calendar optimizations */
    .fc-header-toolbar {
        flex-direction: column;
        gap: 10px;
    }
    
    .fc-toolbar-chunk {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    /* Table responsive */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Modal improvements */
    .modal-content {
        width: 95%;
        max-width: 95%;
        padding: 20px;
        margin: 20px auto;
    }
}

@media (max-width: 480px) {
    /* Extra small devices */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.1rem; }
    
    .card {
        padding: 15px 10px;
    }
    
    /* Compact buttons */
    .btn-primary, .btn-outline {
        font-size: 0.9rem;
        padding: 10px 14px;
    }
}

/* 1. Hamburger Toggle (Always Visible) */
.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 60;
  width: 44px; /* Fixed width for perfect centering */
  height: 44px; /* Fixed height for perfect centering */
  min-width: 44px; /* Touch-friendly size */
  min-height: 44px;
  border-radius: 6px;
  transition: all 0.2s ease;
  margin: 0;
  box-sizing: border-box;
}

.menu-toggle:hover,
.menu-toggle:active {
  background-color: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
  .menu-toggle {
    right: 16px;
    width: 44px;
    height: 44px;
    padding: 0;
    z-index: 70;
    top: 50%;
    transform: translateY(-50%);
  }
}

@media (max-width: 480px) {
  .menu-toggle {
    right: 14px;
    width: 44px;
    height: 44px;
    padding: 0;
    z-index: 70;
    top: 50%;
    transform: translateY(-50%);
  }
}

.menu-toggle:focus-visible {
  outline: 3px solid rgba(3,120,255,0.16);
  outline-offset: 4px;
  border-radius: 4px;
}

.menu-toggle .hamburger {
  display: block;
  width: 22px;
  height: 2px;
  background: #004080; /* Blue to match header text color */
  position: relative;
  margin: 0 auto;
  top: 0;
  left: 0;
  right: 0;
  flex-shrink: 0;
}

/* Ensure hamburger is visible against header background */
.menu-toggle .hamburger,
.menu-toggle .hamburger::before,
.menu-toggle .hamburger::after {
  background: #004080;
}

.menu-toggle .hamburger::before,
.menu-toggle .hamburger::after {
  content: '';
  position: absolute;
  left: 0;
  width: 22px;
  height: 2px;
  background: inherit;
  transition: transform 180ms ease, opacity 180ms ease;
}

.menu-toggle .hamburger::before { 
  top: -7px;
  left: 0;
}
.menu-toggle .hamburger::after { 
  top: 7px;
  left: 0;
}


/* 2. Slide-out Drawer (Always enabled) */
.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: #ffffff;
  z-index: 70; /* Higher than header */
  box-shadow: -10px 0 30px rgba(2,6,23,0.18);
  padding: 60px 20px 20px 20px; /* Top padding for close button area */
  display: flex;
  flex-direction: column;
  gap: 10px;
  
  transform: translateX(100%); /* Hidden by default */
  opacity: 1; /* Always opaque when visible */
}

/* Drawer Open/Close Animations */
header.site-header.open #mobile-menu {
  animation: drawerIn 320ms cubic-bezier(.2,.9,.2,1) forwards;
}
header.site-header:not(.open) #mobile-menu {
  animation: drawerOut 240ms cubic-bezier(.2,.9,.2,1) forwards; /* Only plays when closing if class was present */
  /* Note: On initial load without 'open' class, this might run. 
     Usually acceptable, or we can rely on JS to handle initial state. */
}

/* 3. Backdrop Overlay */
.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,0.45);
  z-index: 65; /* Below menu, above everything else */
  opacity: 0;
  pointer-events: none;
}

header.site-header.open + .mobile-backdrop,
.mobile-backdrop.open {
  display: block;
  animation: overlayFadeIn 240ms ease forwards;
  pointer-events: auto;
}

header.site-header:not(.open) + .mobile-backdrop {
  animation: overlayFadeOut 200ms ease forwards;
}


/* 4. Close Button inside Drawer */
.mobile-menu .close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(6,56,90,0.06);
  color: #06385a;
  border: 1px solid rgba(6,56,90,0.09);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 72;
}

.mobile-menu .close-btn:hover {
  background: rgba(6,56,90,0.1);
}

/* 5. Pill Buttons adaptation for Drawer */
/* Overriding styles.css .nav-btn specifically for the drawer context */
.mobile-menu .nav-btn {
  display: flex;
  width: 100%;
  max-width: none; /* Override the 140px limit */
  justify-content: flex-start; /* Align left */
  height: auto;
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 1.05rem;
  background: #f8fbff;
  border: 1px solid rgba(6,56,90,0.08);
}

.mobile-menu .nav-btn:hover {
  background: #eef6fb;
  transform: translateX(-2px); /* Slight left nudge instead of up */
}

.mobile-menu .nav-btn .nav-label {
  display: inline-block; /* Ensure label is always shown */
  margin-left: 12px;
}

.mobile-menu .nav-btn .nav-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}


/* Keyframes */
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes overlayFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes drawerIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes drawerOut {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}

/* User profile section positioning on header (desktop, right-aligned) */
header.site-header > div[style*="position: absolute; right: 90px"] {
  display: flex;
}

/* Hide user profile on mobile/tablet to prevent overlap with hamburger */
@media (max-width: 900px) {
  header.site-header > div[style*="position: absolute; right: 90px"] {
    display: none;
  }
}

/* Touch-friendly button sizes (minimum 44x44px) */
button, .btn, .btn-primary, .btn-outline, a.button, input[type="submit"], input[type="button"] {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 20px;
  touch-action: manipulation; /* Prevents double-tap zoom delay */
}

/* Improve touch targets for small buttons */
.btn-sm {
  min-height: 36px;
  min-width: 36px;
  padding: 8px 16px;
}

/* Better spacing for mobile */
@media (max-width: 768px) {
  button, .btn {
    padding: 14px 24px; /* Larger padding on mobile */
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
  
  /* Adequate spacing between clickable elements */
  a, button, input, select, textarea {
    margin-bottom: 12px;
  }
  
  /* Prevent accidental text selection on buttons */
  button, .btn {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* Additional breakpoints */
@media (max-width: 480px) {
  .mobile-menu {
    width: 280px;
    max-width: 90vw;
  }
  
  button, .btn {
    width: 100%; /* Full-width buttons on very small screens */
    margin-bottom: 10px;
  }
}

@media (max-width: 320px) {
  .mobile-menu {
    width: 100vw;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
   .mobile-menu,
   .mobile-backdrop,
   .menu-toggle .hamburger::before,
   .menu-toggle .hamburger::after {
     animation: none !important;
     transition: none !important;
   }
}

/* Prevent double-tap zoom on buttons and links */
a, button, input, select, textarea {
  touch-action: manipulation;
}

/* Improve scrolling on mobile */
html {
  -webkit-overflow-scrolling: touch;
  overflow-scrolling: touch;
}
