/* ===== Mobile-First Media Queries ===== */

/* Enhanced Mobile Hero Section */
@media (max-width: 768px) {
    .hero {
        min-height: 100vh;
        padding: 120px 0 80px;
        background-attachment: scroll;
        background-position: center 30%;
    }
    
    .hero-content {
        padding: 0 16px;
    }
    
    .hero h1 {
        font-size: 2.5rem;
        margin-bottom: 1rem;
        line-height: 1.1;
    }
    
    .hero p {
        font-size: 1.1rem;
        margin-bottom: 1.5rem;
        line-height: 1.5;
    }
    
    .hero::before {
        background: 
            radial-gradient(circle at 20% 80%, rgba(212, 175, 55, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 80% 20%, rgba(212, 175, 55, 0.05) 0%, transparent 50%);
    }
}

/* Enhanced Mobile Menu Styles */
@media (max-width: 768px) {
    .mobile-menu {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
        cursor: pointer;
        color: var(--primary-color);
        transition: all 0.3s ease;
        padding: 0.5rem;
        border-radius: 4px;
        border: none;
        background: none;
        z-index: 1001;
    }

    .mobile-menu:hover {
        background: rgba(212, 175, 55, 0.1);
    }

    .mobile-menu.active {
        color: var(--secondary-color);
    }

    nav ul {
        position: fixed;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--white);
        flex-direction: column;
        padding: 2rem 1.5rem;
        gap: 1.5rem;
        box-shadow: var(--shadow-lg);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 1000;
        display: none;
        height: auto;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }

    nav ul.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
        display: flex;
    }

    nav a {
        font-size: 1.1rem;
        padding: 0.75rem 0;
        display: block;
        text-align: center;
        border-bottom: 1px solid var(--border-color);
        text-decoration: none;
        color: var(--text-color);
        font-weight: 500;
        transition: var(--transition);
    }

    nav a:last-child {
        border-bottom: none;
    }

    nav a:hover {
        color: var(--secondary-color);
    }

    /* Body lock when menu is open */
    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    /* Enhanced menu backdrop */
    body.menu-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
}

/* Enhanced Mobile Booking Form */
@media (max-width: 768px) {
    .booking-form {
        padding: 1.25rem;
        margin: 0 -16px;
        border-radius: 0;
        box-shadow: none;
    }
    
    .form-step {
        padding: 0;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 16px;
        border-radius: 8px;
    }
    
    .time-slots {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .time-slot {
        padding: 12px 8px;
        font-size: 0.85rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .form-navigation {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem 0;
        margin: 2rem -1.25rem -1.25rem;
        border-top: 1px solid var(--border-color);
    }
    
    .form-navigation .btn {
        padding: 14px 20px;
        font-size: 1rem;
        font-weight: 600;
    }
    
    /* Improved step indicator */
    .booking-steps {
        gap: 0.5rem;
        margin-bottom: 1.5rem;
        padding: 0 1rem;
    }
    
    .step {
        flex: 1;
        gap: 0.5rem;
    }
    
    .step-number {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .step-label {
        font-size: 0.75rem;
        text-align: center;
    }
}

/* Small Mobile Devices (320px - 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    /* Header & Navigation */
    .header-content {
        padding: 0.75rem 0;
    }

    .logo {
        font-size: 1.5rem;
    }

    .mobile-menu {
        display: block;
        font-size: 1.25rem;
        padding: 0.25rem;
    }

    nav ul {
        position: fixed;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--white);
        flex-direction: column;
        padding: 2rem 1.5rem;
        gap: 1.5rem;
        box-shadow: var(--shadow-lg);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 999;
    }

    nav ul.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    nav a {
        font-size: 1.1rem;
        padding: 0.75rem 0;
        display: block;
        text-align: center;
        border-bottom: 1px solid var(--border-color);
    }

    nav a:last-child {
        border-bottom: none;
    }

    /* Hero Section */
    .hero {
        min-height: 100vh;
        padding: 100px 0 60px;
        background-position: center 40%;
    }

    .hero-content {
        padding: 0;
    }

    .hero h1 {
        font-size: 2rem;
        margin-bottom: 1rem;
        line-height: 1.2;
    }

    .hero p {
        font-size: 1rem;
        margin-bottom: 2rem;
        line-height: 1.5;
    }

    .btn {
        width: 100%;
        max-width: 280px;
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
    }

    /* Sections */
    section {
        padding: 60px 0;
    }

    section h2 {
        font-size: 1.75rem;
        margin-bottom: 2rem;
    }

    /* Services - UPDATED FOR IMG TAGS */
    .services-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin-top: 2rem;
    }

    .service-card {
        margin: 0 auto;
        max-width: 100%;
    }

    .service-img {
        height: 200px;
    }

    .service-img img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .service-content {
        padding: 1.5rem;
    }

    .service-content h3 {
        font-size: 1.25rem;
    }

    .price {
        font-size: 1.5rem;
    }

    /* Gallery */
    .gallery-filters {
        gap: 0.5rem;
        margin-bottom: 2rem;
    }

    .filter-btn {
        padding: 0.625rem 1rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .gallery-item {
        aspect-ratio: 4/3;
    }

    .gallery-overlay {
        padding: 1.5rem;
    }

    .overlay-content h3 {
        font-size: 1.1rem;
    }

    .overlay-content p {
        font-size: 0.85rem;
    }

    /* Booking Section */
    .booking-steps {
        flex-direction: column;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }

    .booking-steps::before {
        display: none;
    }

    .step {
        flex-direction: row;
        gap: 1rem;
        width: 100%;
        max-width: 280px;
    }

    .step-number {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .step-label {
        text-align: left;
        font-size: 0.85rem;
    }

    .booking-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .booking-form {
        padding: 1.5rem;
        order: 2;
    }

    .calendar-container {
        padding: 1.5rem;
        position: static;
        order: 1;
    }

    .form-group {
        margin-bottom: 1.5rem;
    }

    .form-control {
        padding: 0.875rem 1rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .time-slots {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .time-slot {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    .form-navigation {
        flex-direction: column;
        gap: 1rem;
        margin-top: 1.5rem;
    }

    .form-navigation .btn {
        width: 100%;
    }

    /* Barber Section */
    .barber-profile {
        grid-template-columns: 1fr;
        gap: 2rem;
        margin-top: 2rem;
        text-align: center;
    }

    .barber-image {
        max-width: 280px;
        margin: 0 auto;
    }

    .barber-bio h3 {
        font-size: 1.75rem;
    }

    .title {
        font-size: 1.1rem;
    }

    .barber-bio p {
        font-size: 1rem;
        text-align: left;
    }

    /* Footer */
    footer {
        padding: 50px 0 20px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        text-align: center;
    }

    .footer-column h3 {
        font-size: 1.25rem;
    }

    .social-links {
        justify-content: center;
        gap: 0.75rem;
    }

    .social-links a {
        width: 42px;
        height: 42px;
    }

    /* Lightbox */
    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .lightbox-nav {
        padding: 0 10px;
    }

    .lightbox-nav button {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }

    /* Payment */
    .payment-fields-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .payment-option {
        padding: 1rem;
    }

    /* Alerts */
    .alert {
        padding: 1rem;
        font-size: 0.9rem;
    }
}

/* Small Mobile Enhancements */
@media (max-width: 480px) {
    .booking-container {
        gap: 1rem;
    }
    
    .calendar-container {
        padding: 1rem;
        margin: 0 -16px;
        border-radius: 0;
    }
    
    .time-slots {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Improved touch targets */
    .filter-btn,
    .load-more-btn,
    .view-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Better gallery layout for mobile */
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .gallery-item {
        aspect-ratio: 4/3;
    }
    
    /* Enhanced payment form for mobile */
    .payment-details {
        padding: 1.5rem;
    }
    
    #card-container {
        min-height: 120px;
    }
    
    #sq-credit-card {
        padding: 16px 20px;
        font-size: 1.1rem;
    }
    
    /* Mobile menu adjustments */
    nav ul {
        padding: 1.5rem 1rem;
        gap: 1rem;
    }

    nav a {
        font-size: 1rem;
        padding: 1rem 0;
    }

    .mobile-menu {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
}

/* Extra Small Mobile Devices (under 320px) */
@media (max-width: 320px) {
    .container {
        padding: 0 12px;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .services-grid,
    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .time-slots {
        grid-template-columns: 1fr;
    }

    .filter-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .booking-form,
    .calendar-container {
        padding: 1.25rem;
    }
}

/* Mobile Landscape Orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
        padding: 100px 0 60px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    nav ul {
        max-height: 70vh;
        overflow-y: auto;
        padding: 1rem 1.5rem;
    }

    nav a {
        padding: 0.5rem 0;
        font-size: 1rem;
    }
}

/* High-DPI Mobile Screens */
@media (max-width: 480px) and (-webkit-min-device-pixel-ratio: 2) {
    .hero {
        background-attachment: scroll;
    }
}

/* High-DPI Screens Optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero {
        background-image: 
            linear-gradient(135deg, rgba(26, 26, 26, 0.85) 0%, rgba(45, 45, 45, 0.8) 100%),
            url('https://i.imgur.com/QJA9Ptk.jpeg');
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .service-card:hover,
    .gallery-item:hover,
    .btn:hover {
        transform: none;
    }

    .service-card:active,
    .gallery-item:active,
    .btn:active {
        transform: scale(0.98);
    }

    .time-slot {
        min-height: 44px; /* Minimum touch target size */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .filter-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Improve touch scrolling */
    .gallery-filters {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        padding-bottom: 10px;
        margin-left: -8px;
        margin-right: -8px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .gallery-filters::-webkit-scrollbar {
        display: none;
    }
}

/* Better touch interactions */
@media (hover: none) and (pointer: coarse) {
    .service-card,
    .gallery-item,
    .btn {
        transition: transform 0.1s ease;
    }
    
    .service-card:active,
    .gallery-item:active,
    .btn:active {
        transform: scale(0.98);
    }
    
    /* Prevent double-tap zoom */
    .booking-form,
    .gallery-grid,
    .services-grid {
        touch-action: manipulation;
    }
}

/* iOS Specific Optimizations */
@supports (-webkit-touch-callout: none) {
    .hero {
        background-attachment: scroll;
        -webkit-background-size: cover;
        background-size: cover;
    }
    
    .booking-form,
    .calendar-container {
        -webkit-overflow-scrolling: touch;
    }
    
    .form-control {
        font-size: 16px; /* Prevents zoom */
    }
    
    .time-slots-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* Android Chrome Address Bar Height Consideration */
@media (max-width: 480px) and (max-height: 700px) {
    .hero {
        min-height: calc(100vh - 56px); /* Account for address bar */
    }
}

/* Foldable Devices Support */
@media (max-width: 480px) and (max-aspect-ratio: 1/1) {
    .container {
        padding: 0 12px;
    }
    
    .hero {
        background-position: center center;
    }
    
    .services-grid,
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

/* Reduced Motion for Mobile */
@media (max-width: 480px) and (prefers-reduced-motion: reduce) {
    .hero::before,
    .service-card,
    .gallery-item,
    .btn {
        animation: none;
        transition: none;
    }
    
    .gallery-item:hover img {
        transform: none;
    }
    
    .hero h1,
    .hero p,
    .hero .btn {
        animation: none;
    }
}

/* Dark Mode for Mobile */
@media (max-width: 480px) and (prefers-color-scheme: dark) {
    header {
        background: rgba(45, 55, 72, 0.95);
        border-bottom-color: rgba(74, 85, 104, 0.3);
    }
    
    .mobile-menu {
        color: var(--white);
    }
    
    nav ul {
        background: #2d3748;
    }
    
    nav a {
        color: var(--text-color);
        border-bottom-color: #4a5568;
    }
}

/* Enhanced focus states for accessibility */
@media (max-width: 768px) {
    .btn:focus,
    .time-slot:focus,
    .filter-btn:focus,
    .mobile-menu:focus {
        outline: 2px solid var(--secondary-color);
        outline-offset: 2px;
    }
    
    .form-control:focus {
        border-color: var(--secondary-color);
        box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
    }
}

/* Smooth transitions for mobile */
@media (max-width: 768px) {
    .form-step {
        transition: opacity 0.3s ease;
    }
    
    .gallery-item {
        transition: transform 0.2s ease;
    }
    
    .gallery-item:active {
        transform: scale(0.98);
    }
}

/* Enhanced mobile header */
@media (max-width: 768px) {
    header {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.95);
    }
    
    .header-scrolled {
        background: rgba(255, 255, 255, 0.98) !important;
    }
}

/* Print Styles for Mobile (if needed) */
@media (max-width: 480px) and (print) {
    .mobile-menu,
    .btn,
    .calendar-container,
    .lightbox,
    .gallery-filters {
        display: none !important;
    }
    
    .hero {
        background: none !important;
        color: #000 !important;
        padding: 60px 0 30px;
    }
    
    .hero h1 {
        color: #000 !important;
        text-shadow: none !important;
    }
}