/* Your existing styles - KEEP THESE */
@media (max-width: 768px) {
  nav                  { display: none !important; }
  .hamburger           { display: flex !important; }
  .mobile-nav          { display: none !important; }
  .mobile-nav.active   { display: flex !important; flex-direction: column; }

  .course-card, .column, .feature, .card {
    flex: 1 1 100% !important;
    max-width: 100% !important;
  }
  img, .image-wrapper img { max-width: 100% !important; height: auto !important; }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 992px) {
  .course-card, .column, .feature, .card {
    flex: 1 1 calc(50% - 1rem) !important;
  }
  .hero h1 { font-size: 3rem !important; }
}

/* mobile chatbox tweaks */
@media (max-width: 768px) {
  .chatbox {
    /* span full width & height of screen bottom */
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 70vh !important;
    border-radius: 0 !important;
    max-height: 100% !important;
  }

  .chatbody, .chat-body {
    /* let the messages scroll inside */
    flex: 1 1 auto !important;
    max-height: calc(70vh - 120px) !important; /* adjust 120px for header+input */
    overflow-y: auto !important;
  }

  .chat-input {
    /* stick input to bottom of chatbox */
    position: sticky !important;
    bottom: 0 !important;
    width: 100% !important;
  }

  .typing-indicator { margin-bottom: 8px !important; }
}

/* ============ NEW STYLES BELOW ============ */

/* ----- IMPROVED CHATBOT MOBILE STYLES ----- */
/* Improved Chatbot Mobile Styles */
@media (max-width: 768px) {
  /* Chat widget positioning */
  .chat-widget {
    bottom: 15px;
    right: 15px;
    gap: 5px; /* Reduce space between elements */
    z-index: 1000; /* Ensure it stays above other content */
  }
  
  /* Make the WhatsApp button smaller on mobile */
  .whatsapp-btn img {
    width: 40px;
    height: 40px;
  }
  
  /* Adjust chat message button */
  .chat-message {
    padding: 8px 12px;
    font-size: 14px;
    max-width: 80%; /* Prevent too wide messages */
  }
  
  /* Message bubbles */
  .bot-msg, .user-msg {
    max-width: 80%;
    padding: 8px 12px;
    font-size: 14px;
    margin-bottom: 8px;
  }
  
  /* Predefined question buttons */
  .chatbox button {
    padding: 6px 8px;
    font-size: 12px;
    margin: 2px;
  }
}

/* ----- IMPROVED FORM MOBILE STYLES ----- */
@media (max-width: 768px) {
  /* Hero overlay for register form */
  /* .hero-overlay {
    width: 90%;
    max-width: 100%;
    padding: 20px 15px;
    margin-top: 20px;
    margin-bottom: 30px;
  } */
  
  /* Form inputs */
  input, textarea, select {
    padding: 12px;
    font-size: 16px; /* Better for touch */
    margin-bottom: 8px;
    box-sizing: border-box;
  }
  
  /* Stack form rows on mobile */
  .form-row {
    flex-direction: column;
    gap: 8px;
  }
  
  /* Submit buttons */
  button[type="submit"], .form-box button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 5px;
  }
  
  /* Contact page form */
  .form-box {
    padding: 20px 15px;
    border-radius: 10px;
    margin-bottom: 20px;
  }
  
  /* Adjust map area in contact page */
  .map-box {
    padding-left: 0;
    margin-top: 25px;
  }
  
  .map-box iframe {
    height: 300px;
  }
}

/* ----- ADDITIONAL RESPONSIVE IMPROVEMENTS ----- */
@media (max-width: 768px) {
  /* Header & Navigation */
  .navbar {
    padding: 10px 15px;
  }
  
  .logo span {
    font-size: 18px;
  }
  
  .top-bar {
    padding: 5px 15px;
    font-size: 11px;
  }
  
  /* Mobile navigation items */
  .mobile-nav a {
    padding: 15px;
    text-align: center;
  }
  
  /* Team & About section */
  .team-header-box {
    padding: 15px;
  }
  
  .team-header-box h2 {
    font-size: 1.8rem;
  }
  
  .center-image {
    max-width: 150px;
    margin: 20px auto;
  }
  
  .modal-content {
    width: 95%;
    padding: 20px;
  }
  
  /* Fire Safety Section */
  .fire-safety-container {
    flex-direction: column;
  }
  
  .purple-bar {
    font-size: 16px;
    padding: 10px;
  }
  
  .objectives-box {
    padding: 15px;
  }
  
  .center-firefighter-v2 {
    order: -1; /* Move image to top on mobile */
  }
  
  .firefighter-image-v2 {
    width: 180px;
    margin-bottom: 20px;
  }
  
  /* Footer Section */
  .footer-content {
    display: grid;
    grid-template-columns: 1fr;
    text-align: center;
    padding: 0 15px;
  }
  
  .certification-badges {
    justify-content: center;
    margin: 0 auto;
  }
  
  .certification-badges img {
    height: 80px;
  }
}

@media (max-width: 768px) {
  .full-logo {
    height: 60px !important;
    max-width: 200px !important;
    width: auto !important;
    object-fit: contain;
    display: block;
  }

  .logo {
    padding-left: 4px !important;
    padding-right: 4px !important;
    align-items: center !important;
  }

  .navbar {
    min-height: 48px !important;
    padding: 4px 8px !important;
    flex-wrap: nowrap !important;
  }

  .hero {
    margin-top: 36px !important;  /* Adjust to match banner height as needed */
  }
}

/* ----- UPDATED HERO SECTION WITH IMPROVED MOBILE BACKGROUND ----- */
@media (max-width: 768px) {
  .hero {
    position: relative !important;
    width: 100vw !important;
    min-height: 60vh !important; /* Changed from 420px to viewport height */
    max-height: 70vh !important; /* Prevent too tall on some devices */
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    background-image: url('../images/fire-background.png');
    background-size: cover !important;
    background-repeat: no-repeat !important;
    background-position: center center !important; /* Changed from center 35% */
    background-attachment: scroll !important; /* Prevents issues on mobile */
    display: flex !important;
    align-items: flex-end !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
  }

  .hero-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.4) !important;
    z-index: 1 !important;
  }

  .hero-content {
    position: relative !important;
    z-index: 2 !important;
    width: 100% !important;
    padding: 20px 15px !important;
    max-width: 100% !important;
    text-align: left !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  .hero h1 {
    font-size: 1.8rem !important;
    line-height: 1.2 !important;
    margin-bottom: 12px !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8) !important;
    color: white !important;
  }

  .hero .tagline {
    font-size: 1rem !important;
    margin-bottom: 10px !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8) !important;
    color: white !important;
  }

  .hero p {
    font-size: 0.9rem !important;
    margin-bottom: 18px !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    line-height: 1.4 !important;
  }

  .learn-more-btn {
    padding: 12px 24px !important;
    font-size: 14px !important;
    margin-top: 10px !important;
  }
}

/* Extra adjustments for very tall/narrow screens like Samsung S25 */
@media (max-width: 480px) and (min-height: 800px) {
  .hero {
    min-height: 55vh !important;
    max-height: 65vh !important;
    background-position: center 40% !important; /* Adjust focal point for tall screens */
    background-attachment: scroll !important; /* Force scroll for Samsung devices */
  }
}

/* Extra adjustments for shorter/wider screens */
@media (max-width: 768px) and (max-height: 600px) {
  .hero {
    min-height: 70vh !important;
    max-height: 80vh !important;
    background-position: center 30% !important;
    background-attachment: scroll !important;
  }
}

/* Samsung S25 and similar tall narrow screens - Background Image Fix */
@media (max-width: 480px) and (min-aspect-ratio: 2/3) and (max-aspect-ratio: 1/2) {
  /* Index page hero section - Samsung S25 fix */
  .hero {
    background-attachment: scroll !important; /* Remove fixed attachment */
    background-size: cover !important;
    background-position: center 20% !important; /* Adjust focal point */
    min-height: 65vh !important;
    max-height: 75vh !important;
    -webkit-background-size: cover !important;
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
  }
  
  .hero-content {
    padding: 25px 15px !important;
  }
  
  .hero h1 {
    font-size: 1.7rem !important;
    line-height: 1.1 !important;
  }
  
  .hero .tagline {
    font-size: 0.95rem !important;
  }
  
  .hero p {
    font-size: 0.85rem !important;
    line-height: 1.3 !important;
  }
}

/* About page hero section - Samsung S25 fix */
@media (max-width: 480px) and (min-aspect-ratio: 2/3) and (max-aspect-ratio: 1/2) {
  .hero {
    background-attachment: scroll !important; /* Critical for Samsung S25 */
    background-size: cover !important;
    background-position: center center !important;
    min-height: 50vh !important;
    max-height: 60vh !important;
    -webkit-background-size: cover !important;
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
  }
  
  .hero-overlay {
    background: rgba(0, 0, 0, 0.5) !important; /* Slightly darker for better text visibility */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
  }
  
  .hero-overlay h1 {
    font-size: 1.5rem !important;
    line-height: 1.2 !important;
    margin-bottom: 0.8rem !important;
  }
  
  .hero-overlay p {
    font-size: 0.85rem !important;
    line-height: 1.4 !important;
  }
}

/* Samsung Galaxy S25 Ultra specific (if needed) */
@media (max-width: 480px) and (min-height: 900px) and (max-height: 1000px) {
  .hero {
    background-attachment: scroll !important;
    background-size: cover !important;
    background-position: center 25% !important;
    min-height: 55vh !important;
    max-height: 65vh !important;
    -webkit-background-size: cover !important;
  }
}

/* Fix for any device with problematic background-attachment */
@media (max-width: 768px) {
  .hero {
    background-attachment: scroll !important; /* Force scroll on all mobile */
  }
  
  /* Ensure images scale properly */
  .hero-overlay {
    -webkit-transform: translateZ(0); /* Hardware acceleration fix */
    transform: translateZ(0);
  }
}

/* Additional fix for Samsung devices with high pixel density */
@media (max-width: 480px) and (-webkit-min-device-pixel-ratio: 3) {
  .hero {
    background-attachment: scroll !important;
    background-size: cover !important;
    background-position: center center !important;
    -webkit-background-size: cover !important;
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
  }
}

/* Fallback for any mobile device having background image issues */
@media (max-width: 768px) {
  /* Force scroll attachment for all mobile backgrounds */
  .hero, 
  .faq-section,
  [style*="background-image"] {
    background-attachment: scroll !important;
    -webkit-background-attachment: scroll !important;
  }
  
  /* Prevent background image stretching issues */
  .hero {
    background-size: cover !important;
    background-repeat: no-repeat !important;
    -webkit-background-size: cover !important;
  }
}

/* Samsung S25 specific viewport fix */
@media (max-width: 480px) and (orientation: portrait) {
  .hero {
    height: 60vh !important;
    min-height: 60vh !important;
    max-height: 70vh !important;
    background-attachment: scroll !important;
    background-position: center 30% !important;
  }
  
  /* Ensure proper text positioning */
  .hero-content {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    height: 100% !important;
    padding: 20px 15px !important;
  }
}

/* Specific adjustments for Samsung Galaxy aspect ratios */
@media (max-width: 480px) and (min-aspect-ratio: 9/20) {
  .hero {
    min-height: 50vh !important;
    background-position: center 45% !important;
    background-attachment: scroll !important;
  }
  
  .hero-content {
    padding: 15px 12px !important;
  }
  
  .hero h1 {
    font-size: 1.6rem !important;
  }
  
  .hero .tagline,
  .hero p {
    font-size: 0.85rem !important;
  }
}

/* Fallback for ultra-wide or unusual aspect ratios */
@media (max-width: 768px) and (max-aspect-ratio: 1/2) {
  .hero {
    min-height: 45vh !important;
    background-size: cover !important;
    background-position: center center !important;
    background-attachment: scroll !important;
  }
}

@media (max-width: 768px) {
  /* Align fire safety objectives section vertically and center content */
  .perform-training-container-v2 {
    flex-direction: column !important;
    gap: 18px !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
  }

  .perform-side {
    width: 100% !important;
    align-items: center !important;
    gap: 18px !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .perform-item-v2 {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 95% !important;
    margin: 0 auto !important;
    text-align: left !important;
  }

  .number-circle-v2 {
    margin-right: 14px !important;
    margin-bottom: 0 !important;
    flex-shrink: 0 !important;
  }

  .center-firefighter-v2 {
    order: 0;
    margin: 15px auto 0 auto !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
  }
  .firefighter-image-v2 {
    width: 160px !important;
    max-width: 60vw !important;
    margin: 0 auto 8px auto !important;
    display: block !important;
  }
}

@media (max-width: 768px) {
  .course-card {
    height: auto !important;             /* Remove fixed height for mobile */
    min-height: 430px !important;        /* (optional) Minimum so all cards look equal */
  }
  .course-details {
    min-height: 180px !important;        /* Reduce min-height for smaller screens */
    padding-bottom: 20px !important;     /* Ensures space at the bottom */
  }
  .btn-info {
    margin-top: 18px !important;
    margin-bottom: 0 !important;
  }
}

@media (max-width: 768px) {
  .feature.left .item,
  .feature.right .item {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: left;
  }
  .number-circle {
    margin-bottom: 0;
    margin-right: 0.7rem;
  }
}

@media (max-width: 768px) {
  /* Reduce space after the last fire safety item on mobile */
  .perform-training-container-v2 .perform-side:last-child {
    margin-bottom: 0 !important;
  }
  .perform-training-container-v2 .perform-side:last-child .perform-item-v2:last-child {
    margin-bottom: 0 !important;
  }
  /* Optionally, reduce section padding too if the gap is still too large */
  #fire-safety-coverage {
    padding-bottom: 24px !important;
  }
}
