/* Mobile-specific styles */
@media (max-width: 768px) {
    /* Define CSS variables for dropdown heights */
    :root {
        --dropdown-height: 0px;
    }
    
    /* General mobile adjustments */
    body {
        font-size: 14px;
        padding-top: 60px; /* Reduced padding for mobile */
    }
    
    main {
        margin-top: 0; /* Reset margin since we're using body padding */
        padding-top: 0;
    }
    
    /* Navbar adjustments for mobile */
    .navbar {
        height: 60px; /* Smaller navbar for mobile */
        padding: 0.5rem 4%;
        display: flex;
        align-items: center;
    }
    
    /* Logo sizing - centered */
    .logo {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }
    
    /* Hide CTA button on mobile */
    .navbar-cta {
        display: none;
    }
    
    /* Hamburger styling - positioned at the left */
    .hamburger {
        z-index: 1001;
        position: relative;
        display: flex;
        flex-direction: column;
        gap: 5px;
        cursor: pointer;
        order: -1; /* Move to the left */
        margin-right: auto;
        margin-left: 0;
    }
    
    .hamburger span {
        width: 25px;
        height: 3px;
        background-color: #fff;
        transition: all 0.3s ease;
    }
    
    /* Close button for mobile menu - REMOVE THIS SECTION */
    .menu-close {
        display: none !important; /* Hide the close button completely */
    }
    
    .menu-close::before,
    .menu-close::after {
        display: none !important;
    }
    
    .nav-links.active .menu-close {
        display: none !important;
    }
    
    /* Use the hamburger as the close button instead */
    .hamburger.active {
        z-index: 1002 !important; /* Ensure it's above the menu */
        position: fixed !important; /* Keep it in position when menu is open */
        top: 18px !important; /* Position it properly */
        left: 4% !important; /* Match the standard padding */
        transition: all 0.3s ease; /* Smooth transition for position change */
    }
    
    /* Make hamburger transform to X when active */
    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px) !important;
        background-color: #fff !important;
    }
    
    .hamburger.active span:nth-child(2) {
        opacity: 0 !important;
        background-color: #fff !important;
    }
    
    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px) !important;
        background-color: #fff !important;
    }
    
    /* Mobile Navigation Panel - dropdown from top */
    .nav-links {
        position: fixed;
        flex-direction: column;
        align-items: flex-start;
        gap: 1.2rem;
        background: #c41e3a;
        width: 100%;
        margin: 0;
        padding: 6rem 2rem 2rem;
        display: none;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 999;
        box-shadow: 0 4px 8px rgba(0,0,0,0.3);
        transition: transform 0.3s ease;
        transform: translateY(-100%);
        overflow-y: auto;
    }
    
    /* Ensure smooth scrolling in the navigation panel */
    .nav-links.scrollable {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        padding-bottom: 100px; /* Add extra padding at the bottom for better scrolling */
    }
    
    .nav-links.active {
        display: flex;
        transform: translateY(0);
    }
    
    /* Divider lines between menu items */
    .nav-links > a,
    .dropdown {
        border-bottom: 1px dotted rgba(255, 255, 255, 0.4);
        padding-bottom: 0.8rem;
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .nav-links > a:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }
    
    /* Main navigation items */
    .nav-links > a {
        font-size: 1.6rem !important;
        padding: 0.5rem 0;
        width: 100%;
        text-align: left;
        color: #fff !important;
        font-weight: bold;
        text-transform: uppercase;
        font-family: 'Hauser Bold', sans-serif;
        letter-spacing: 1px;
    }
    
    .nav-links > a.active,
    .nav-links > a:hover {
        color: #1a1a1a !important;
    }
    
    /* Dropdown styling for "CORSI" */
    .dropdown {
        width: 100%;
        text-align: left;
        position: relative;
        display: flex;
        flex-direction: column;
        gap: 0;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 0 0.5rem 0 !important;
        border-bottom: 1px dotted rgba(255, 255, 255, 0.4);
        padding-bottom: 0.8rem;
    }
    
    /* Adjust dropdown to have proper spacing */
    .dropdown.open {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
        border-bottom: none;
    }
    
    /* Corsi main title with dropdown arrow */
    .dropdown > a {
        font-size: 1.6rem !important;
        padding: 0.5rem 0;
        color: #fff !important;
        font-weight: bold;
        margin-bottom: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        text-transform: uppercase;
        font-family: 'Hauser Bold', sans-serif;
        letter-spacing: 1px;
    }
    
    /* Dropdown arrow styling */
    .dropdown > a::after {
        content: '▼';
        display: inline-block;
        font-size: 0.8rem;
        margin-left: 0.5rem;
        transition: transform 0.3s ease;
    }
    
    /* Rotate arrow when dropdown is open */
    .dropdown.open > a::after {
        transform: rotate(180deg);
    }
    
    .dropdown > a.active,
    .dropdown > a:hover {
        color: #1a1a1a !important;
    }
    
    /* Submenu items container - hidden by default */
    .dropdown-content {
        position: static;
        width: 100%;
        box-shadow: none !important;
        display: none !important;
        background-color: transparent !important;
        margin: 0.5rem 0 0.8rem 1rem !important;
        padding: 0 !important;
        max-height: none;
        overflow: visible;
        border: none !important;
        outline: none !important;
        border-radius: 0 !important;
        transition: all 0.3s ease;
    }
    
    /* Show dropdown content when open */
    .dropdown.open .dropdown-content {
        display: block !important;
    }
    
    /* Add bottom border after dropdown content to separate it from next item */
    .dropdown.open::after {
        content: '';
        display: block;
        width: 100%;
        border-bottom: 1px dotted rgba(255, 255, 255, 0.4);
        margin-top: 0.8rem;
    }
    
    /* Individual course title links */
    .dropdown-content a {
        padding: 0.4rem 0 !important;
        font-size: 1.2rem !important;
        text-align: left !important;
        color: #fff !important;
        display: block;
        background-color: transparent !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 0 0.3rem 0 !important;
        border-radius: 0 !important;
        font-weight: normal;
        text-transform: uppercase;
        font-family: 'Hauser Bold', sans-serif;
        letter-spacing: 1px;
        border-bottom: none !important;
        position: relative;
        z-index: 2;
    }
    
    .dropdown-content a:last-child {
        margin-bottom: 0 !important;
    }
    
    .dropdown-content a.active,
    .dropdown-content a:hover {
        color: #1a1a1a !important;
    }
    
    /* Fix for main logo in home page */
    .hero-logo {
        margin-top: 60px; /* Add more space above the logo */
        position: relative;
        z-index: 1; /* Ensure logo is visible */
    }
    
    .hero-logo img {
        max-width: 180px !important; /* Smaller logo for mobile */
        margin: 0 auto;
    }
    
    /* Fix for title font size in home page */
    .hero h2, .formazione-professional h1, .formazione-professional h2, .section-title {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    /* Make hero area taller to accommodate content */
    .hero {
        height: auto !important;
        min-height: auto !important;
        padding-bottom: 30px;
        padding-top: 20px;
        margin-bottom: 0;
    }
    
    /* Fix for button positioning to avoid overlap with sections */
    .hero .cta-button, .hero a.cta-button {
        margin-bottom: 20px !important;
        display: inline-block !important;
        position: relative;
        z-index: 2;
    }
    
    /* Mission section spacing */
    .mission-section {
        padding-top: 0 !important;
        margin-top: 0 !important;
        position: relative;
        z-index: 3;
    }
    
    /* Use flex-grow to push other nav links down when dropdown is open */
    .nav-links > a:not(.dropdown a) {
        transition: margin-top 0.3s ease;
        position: relative;
        z-index: 1;
    }
    
    /* IMPORTANT: Fix for the mobile menu dropdown overlap */
    /* Target the CALENDARIO link specifically with ID */
    #calendario-link {
        transition: margin-top 0.3s ease;
    }
    
    /* Remove any hardcoded margins that would interfere with our JS solution */
    .dropdown.open + a + a {
        margin-top: 1rem !important; /* Keep only minimal spacing for Contatti link */
    }
    
    /* No fallback fixed spacing - using JS for dynamic calculation */
    
    /* Course pages */
    .courses-page {
        padding: 10px 10px 20px; /* Reduced top padding to match desktop */
    }
    
    .page-title {
        height: 15px !important; /* Further reduce space on mobile */
    }
    
    .page-title h1 {
        font-size: 1.8em;
    }
    
    .page-title p {
        font-size: 1em;
    }
    
    .intro-section {
        padding: 20px 15px;
    }
    
    .intro-section h2 {
        font-size: 1.5em;
    }
    
    .course-levels {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .course-card {
        padding: 20px 15px;
    }
    
    .course-header h2 {
        font-size: 1.5em;
    }
    
    .course-content h3 {
        font-size: 1.2em;
    }
    
    /* Course sections on home page */
    .course-section-content {
        flex-direction: column !important;
        gap: 0 !important; /* Remove any gap causing white space */
    }
    
    .course-section-text, 
    .course-section-image {
        width: 100% !important;
        padding: 30px 20px !important;
        margin: 0 !important; /* Remove any margin causing white space */
    }

    /* Ensure the proper order: title, text, image */
    .course-section-image {
        order: 2 !important;
    }
    
    .course-section-text {
        order: 1 !important;
    }
    
    /* Remove white space between image and text containers */
    .course-section-text + .course-section-image,
    .course-section-image + .course-section-text {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Remove box-shadow from images */
    .course-section-image img {
        box-shadow: none !important;
        border-radius: 0 !important;
        display: block !important; /* Remove any inline spacing */
        margin: 0 !important;
        width: 100% !important;
    }
    
    /* Fix course section backgrounds on mobile to match desktop */
    .course-section {
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important; /* Remove any margin causing white space */
    }
    
    /* Ensure training section has no padding/margin causing white space */
    .training-course-sections {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Remove any spaces between course sections */
    .course-section + .course-section {
        margin-top: 0 !important;
    }
    
    /* Default background for course sections */
    .course-section-text {
        background-color: #1a1a1a !important;
    }
    
    /* Specific styling for Handgun section */
    .handgun-section .course-section-text,
    .course-section:nth-of-type(1) .course-section-text,
    div[id="handgun"] .course-section-text {
        background-color: #232323 !important;
    }
    
    /* Specific styling for Combined section */
    .course-section:nth-of-type(3) .course-section-text {
        background-color: #232323 !important;
    }
    
    /* Ensure RIFLE section has correct background */
    .rifle-section .course-section-text,
    .course-section:nth-of-type(2) .course-section-text {
        background-color: #1a1a1a !important;
    }
    
    /* Ensure VTAC section has correct background */
    .vtac-section .course-section-text,
    .course-section:nth-of-type(4) .course-section-text {
        background-color: #1a1a1a !important;
    }
    
    /* Make sure backgrounds are applied consistently in mobile view */
    .course-section-content {
        background-color: transparent !important;
        position: relative !important; /* For the overlay effect */
        overflow: hidden !important; /* Keep the overlay within bounds */
    }
    
    /* Add hover/touch effect with red overlay */
    .course-section-content::before {
        content: "" !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background-color: rgba(196, 30, 58, 0) !important;
        z-index: 2 !important;
        transition: background-color 0.3s ease !important;
        pointer-events: none !important;
    }
    
    /* Apply the effect on active state for mobile touch */
    .course-section a:active .course-section-content::before {
        background-color: rgba(196, 30, 58, 0.2) !important;
    }
    
    /* Make title change color on active state for mobile */
    .course-section a:active .section-title {
        color: #c41e3a !important;
    }
    
    /* Apply scale effect to images on active state for mobile */
    .course-section a:active .course-section-image img {
        transform: scale(1.05) !important;
    }
    
    /* Ensure images scale smoothly */
    .course-section-image img {
        transition: transform 0.5s ease !important;
    }
    
    /* Apply background to image containers based on their section */
    .handgun-section .course-section-image,
    .course-section:nth-of-type(1) .course-section-image,
    div[id="handgun"] .course-section-image {
        background-color: #232323 !important;
    }
    
    .course-section:nth-of-type(3) .course-section-image {
        background-color: #232323 !important;
    }
    
    .rifle-section .course-section-image,
    .course-section:nth-of-type(2) .course-section-image {
        background-color: #1a1a1a !important;
    }
    
    .vtac-section .course-section-image,
    .course-section:nth-of-type(4) .course-section-image {
        background-color: #1a1a1a !important;
    }
    
    /* Ensure images don't get hidden by background */
    .course-section-image img {
        position: relative;
        z-index: 1;
    }
    
    .course-section-text h2 {
        font-size: 1.3em !important;
    }
    
    /* Calendar page */
    .calendar-page {
        padding: 20px 10px;
    }
    
    .calendar-container {
        padding: 15px 10px;
    }
    
    .calendar-month {
        font-size: 2.2em !important;
    }
    
    .calendar-nav {
        position: static !important;
        margin-bottom: 15px;
    }
    
    .calendar-header {
        flex-direction: column;
    }
    
    .calendar-grid {
        gap: 5px;
    }
    
    .calendar-day {
        padding: 5px;
        font-size: 0.8em;
        min-height: 50px;
    }
    
    .calendar-day-name {
        font-size: 0.8em;
    }
    
    /* Contact page */
    .contact-container {
        grid-template-columns: 1fr;
    }
    
    .contact-form, 
    .contact-info {
        padding: 20px 15px;
    }
    
    /* Fix any background issues with course-section-text */
    .course-section-text {
        z-index: 2 !important;
        position: relative !important;
    }
    
    /* Ensure no spacing between any sections */
    .course-section:last-child {
        margin-bottom: 0 !important;
    }
    
    /* Remove any default margins that might be causing spacing */
    .training-course-sections > *,
    .training-course-sections > * > *,
    .training-course-sections > * > * > * {
        margin: 0 !important;
    }
    
    /* Fix the partners section to avoid white space after courses */
    .partners-section {
        margin-top: 0 !important;
        padding-top: 40px !important;
    }
    
    /* Ensure consistent padding in course sections */
    .course-section-text {
        padding: 30px 20px 20px !important;
    }
    
    .course-section-image {
        padding: 0 !important; /* Remove padding from image container */
    }
    
    /* Improve overlay effect */
    .course-section-content::before {
        pointer-events: auto !important; /* Allow the overlay to receive touch events */
    }
    
    /* For touch devices, use this trick to enable hover-like effects */
    @media (hover: none) {
        .course-section a:active .course-section-content::before {
            background-color: rgba(196, 30, 58, 0.2) !important;
        }
        
        .course-section a:active .section-title {
            color: #c41e3a !important;
        }
    }
    
    /* Fix any background issues with course-section-text */
    .course-section-text {
        z-index: 2 !important;
        position: relative !important;
    }
    
    /* Ensure no spacing between any sections */
    .course-section:last-child {
        margin-bottom: 0 !important;
    }
    
    /* Remove any default margins that might be causing spacing */
    .training-course-sections > *,
    .training-course-sections > * > *,
    .training-course-sections > * > * > * {
        margin: 0 !important;
    }
    
    /* Background images for specific course pages on mobile */
    body.handgun-page {
        background: url('../images/Handgun_background.webp') no-repeat center top fixed;
        background-size: cover;
        position: relative;
    }
    
    body.handgun-page::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.75); /* Dark overlay for readability */
        z-index: -1;
    }
    
    body.rifle-page {
        background: url('../images/Rifle_background.webp') no-repeat center top fixed;
        background-size: cover;
        position: relative;
    }
    
    body.rifle-page::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.75); /* Dark overlay for readability */
        z-index: -1;
    }
    
    body.combined-page {
        background: url('../images/Fakta_Bckgrnd_main.webp') no-repeat center top fixed;
        background-size: cover;
        position: relative;
    }
    
    body.combined-page::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.75); /* Dark overlay for readability */
        z-index: -1;
    }
    
    body.vtac-page {
        background: url('../images/vtac_background.webp') no-repeat center top fixed;
        background-size: cover;
        position: relative;
    }
    
    body.vtac-page::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.75); /* Dark overlay for readability */
        z-index: -1;
    }
    
    /* Styling for course pages with background images */
    .handgun-page .intro-section,
    .rifle-page .intro-section,
    .combined-page .intro-section,
    .vtac-page .intro-section {
        background: rgba(25, 25, 25, 0.5) !important;
        color: #fff !important;
        border: none !important;
        box-shadow: none !important;
        margin-top: 10px !important;
        padding: 20px !important;
        border-radius: 4px !important;
    }
    
    .handgun-page .intro-section p,
    .rifle-page .intro-section p,
    .combined-page .intro-section p,
    .vtac-page .intro-section p {
        color: #ddd !important;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
        font-size: 1rem !important;
    }
    
    .handgun-page .intro-section h2,
    .rifle-page .intro-section h2,
    .combined-page .intro-section h2,
    .vtac-page .intro-section h2 {
        color: #fff !important;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
        font-size: 2.8em !important;
    }
    
    /* Make course cards semi-transparent to show background */
    .handgun-page .course-card,
    .rifle-page .course-card,
    .combined-page .course-card,
    .vtac-page .course-card {
        background-color: rgba(25, 25, 25, 0.85) !important;
        color: #fff !important;
        border: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 20px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3) !important;
    }
    
    .handgun-page .course-levels,
    .rifle-page .course-levels,
    .combined-page .course-levels,
    .vtac-page .course-levels {
        padding: 0 10px !important;
    }
    
    .handgun-page .course-header,
    .rifle-page .course-header,
    .combined-page .course-header,
    .vtac-page .course-header {
        border-bottom: 2px solid #c41e3a !important;
    }
    
    .handgun-page .course-header h2,
    .rifle-page .course-header h2,
    .combined-page .course-header h2,
    .vtac-page .course-header h2 {
        color: #fff !important;
    }
    
    .handgun-page .course-header .level,
    .rifle-page .course-header .level,
    .combined-page .course-header .level,
    .vtac-page .course-header .level {
        color: #c41e3a !important;
    }
    
    .handgun-page .course-content h3,
    .rifle-page .course-content h3,
    .combined-page .course-content h3,
    .vtac-page .course-content h3 {
        color: #fff !important;
    }
    
    .handgun-page .course-content p,
    .handgun-page .course-content ul li,
    .rifle-page .course-content p,
    .rifle-page .course-content ul li,
    .combined-page .course-content p,
    .combined-page .course-content ul li,
    .vtac-page .course-content p,
    .vtac-page .course-content ul li {
        color: #ddd !important;
    }
    
    /* Footer adjustments for pages with background */
    .handgun-page footer,
    .rifle-page footer,
    .combined-page footer,
    .vtac-page footer {
        background-color: rgba(0, 0, 0, 0.8) !important;
        margin-top: 30px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    /* Adjust page title for pages with background */
    .handgun-page .page-title,
    .rifle-page .page-title,
    .combined-page .page-title,
    .vtac-page .page-title {
        height: 0 !important;
    }
    
    /* Make images in course cards stand out more */
    .handgun-page .course-content img,
    .rifle-page .course-content img,
    .combined-page .course-content img,
    .vtac-page .course-content img {
        filter: brightness(1.2);
    }
} 