/* Mobile-First Responsive Design Enhancements */

/* ===== MOBILE-FIRST BREAKPOINTS ===== */
/* Extra Small: 320px - 479px (Small phones) */
/* Small: 480px - 767px (Large phones) */
/* Medium: 768px - 1023px (Tablets) */
/* Large: 1024px+ (Desktop) */

/* ===== BASE MOBILE STYLES (320px+) ===== */

/* Enhanced Touch Targets */
.btn,
.auth-btn,
.nav-tab,
.filter-chip,
button,
a {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Typography */
@media (max-width: 479px) {
    :root {
        --font-size-xs: 13px;
        --font-size-sm: 15px;
        --font-size-base: 16px;
        --font-size-md: 18px;
        --font-size-lg: 22px;
        --font-size-xl: 26px;
        --font-size-2xl: 28px;
        --font-size-3xl: 32px;
    }

    body {
        font-size: 16px; /* Prevent zoom on iOS */
        line-height: 1.5;
    }

    h1 { font-size: 28px; }
    h2 { font-size: 24px; }
    h3 { font-size: 20px; }
    h4 { font-size: 18px; }
}

/* ===== HEADER MOBILE OPTIMIZATIONS ===== */

/* Mobile Header */
@media (max-width: 767px) {
    .main-header {
        height: 60px;
        border-bottom: 1px solid var(--gray-200);
    }

    .header-content {
        padding: 0 16px;
        height: 60px;
    }

    .header-left {
        flex: 1;
        margin-left: -8px;
    }

    /* Mobile Logo Styling */
    .logo-image {
        height: 26px !important;
    }

    .logo-container {
        flex-shrink: 0;
    }

    .tagline {
        display: none !important;
    }

    /* Mobile Auth Section - Simplified */
    .auth-section {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .auth-btn {
        padding: 1px 4px;
        font-size: var(--font-size-xs);
        min-height: auto;
        white-space: nowrap;
        border-radius: 2px;
        font-weight: 500;
        line-height: 1.2;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .auth-btn.login-btn {
        background: transparent;
        color: var(--gray-700);
        border: 1px solid var(--gray-300);
    }

    .auth-btn.login-btn:hover {
        background: var(--gray-50);
        border-color: var(--brand-primary);
        color: var(--brand-primary);
    }

    .auth-btn.signup-btn {
        background: var(--brand-primary);
        color: white;
        border: none;
        box-shadow: 0 2px 8px rgba(134, 176, 189, 0.3);
    }

    .auth-btn.signup-btn:hover {
        background: var(--brand-secondary);
        box-shadow: 0 4px 12px rgba(134, 176, 189, 0.4);
        transform: translateY(-1px);
    }

    .contact-btn {
        display: none; /* Hide on mobile to save space */
    }

    /* Hide cart button on very small screens for cleaner header */
    @media (max-width: 380px) {
        .action-nav-btn {
            display: none !important;
        }
    }

    /* Modern Hamburger Menu Button */
    .mobile-menu-btn {
        position: relative;
        width: 44px;
        height: 44px;
        background: var(--gray-50);
        border: 1px solid var(--gray-200);
        border-radius: 12px;
        cursor: pointer;
        padding: 0;
        margin-left: 12px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .mobile-menu-btn:hover {
        background: white;
        border-color: var(--brand-primary);
        box-shadow: 0 4px 12px rgba(134, 176, 189, 0.2);
        transform: translateY(-1px);
    }

    .mobile-menu-btn:active {
        transform: translateY(0);
        box-shadow: 0 2px 8px rgba(134, 176, 189, 0.3);
    }

    /* Hamburger Icon Container */
    .mobile-menu-btn .hamburger-icon {
        position: relative;
        width: 20px;
        height: 16px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .mobile-menu-btn span {
        width: 100%;
        height: 2px;
        background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
        border-radius: 2px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform-origin: center;
    }

    .mobile-menu-btn span:nth-child(1) {
        width: 100%;
    }

    .mobile-menu-btn span:nth-child(2) {
        width: 75%;
        align-self: flex-end;
    }

    .mobile-menu-btn span:nth-child(3) {
        width: 90%;
    }

    /* Active State Animation */
    .mobile-menu-btn.active {
        background: var(--brand-primary);
        border-color: var(--brand-primary);
        box-shadow: 0 6px 20px rgba(134, 176, 189, 0.4);
    }

    .mobile-menu-btn.active span {
        background: white;
        width: 100%;
    }

    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(3px, 3px);
    }

    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }

    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(4px, -4px);
    }
}

/* ===== NAVIGATION MOBILE OPTIMIZATIONS ===== */

/* Hide mobile navigation and hamburger menu on desktop by default */
.main-nav {
    display: none !important;
}

.main-nav .nav-footer,
.main-nav .nav-social-links,
.main-nav .nav-social-link {
    display: none !important;
}

.menu-overlay {
    display: none !important;
}

.mobile-menu-btn {
    display: none !important;
}

@media (max-width: 767px) {
    /* Hide desktop auth buttons on mobile */
    .auth-btn.desktop-only {
        display: none !important;
    }

    /* Show hamburger menu on mobile */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* Modern Glass Overlay Mobile Menu */
    .main-nav {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        opacity: 0;
        visibility: hidden;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        z-index: 999;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }

    .main-nav.active {
        opacity: 1;
        visibility: visible;
    }

    /* Glass menu container */
    .nav-menu-container {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: 24px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15),
                    0 0 0 1px rgba(255, 255, 255, 0.1);
        max-width: 360px;
        width: 100%;
        max-height: 80vh;
        overflow-y: auto;
        transform: scale(0.8) translateY(20px);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .main-nav.active .nav-menu-container {
        transform: scale(1) translateY(0);
    }

    /* Modern Glass Menu Header */
    .nav-header {
        padding: 24px 24px 16px;
        text-align: center;
        border-bottom: 1px solid rgba(134, 176, 189, 0.1);
        background: linear-gradient(135deg,
            rgba(134, 176, 189, 0.08),
            rgba(226, 161, 111, 0.05));
    }

    .nav-header h3 {
        font-size: 20px;
        font-weight: 700;
        margin: 0 0 4px 0;
        color: var(--gray-800);
        background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .nav-header p {
        font-size: 13px;
        opacity: 0.7;
        margin: 0;
        color: var(--gray-600);
        font-weight: 400;
    }

    .nav-tabs {
        flex-direction: column;
        padding: 16px 20px;
        gap: 4px;
        align-items: stretch;
        height: auto;
    }

    .nav-tab {
        width: 100%;
        padding: 16px 16px;
        justify-content: flex-start;
        border: none;
        background: transparent;
        font-size: 16px;
        font-weight: 500;
        text-align: left;
        min-height: 52px;
        border-radius: 12px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        color: var(--gray-700);
        display: flex;
        align-items: center;
        gap: 12px;
        margin: 0;
        text-decoration: none;
    }

    .nav-tab svg {
        width: 18px;
        height: 18px;
        opacity: 0.7;
        transition: all 0.2s ease;
    }

    .nav-tab::before {
        content: '';
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--gray-300);
        transition: all 0.3s ease;
    }

    .nav-tab:hover {
        background: rgba(134, 176, 189, 0.12);
        color: var(--brand-primary);
        transform: translateX(4px);
    }

    .nav-tab:hover svg {
        opacity: 1;
        color: var(--brand-primary);
        transform: scale(1.1);
    }

    .nav-tab.active {
        background: linear-gradient(135deg, rgba(134, 176, 189, 0.15), rgba(226, 161, 111, 0.1));
        color: var(--brand-primary);
        font-weight: 600;
        transform: translateX(4px);
        box-shadow: 0 2px 8px rgba(134, 176, 189, 0.2);
    }

    .nav-tab.active::before {
        background: var(--brand-primary);
        transform: scale(1.5);
        box-shadow: 0 0 8px rgba(134, 176, 189, 0.4);
    }

    /* Mobile Auth Section */
    .mobile-auth-section {
        padding: 16px 20px 20px;
        border-top: 1px solid rgba(134, 176, 189, 0.1);
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .mobile-auth-btn {
        width: 100%;
        padding: 14px 16px;
        border: none;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 600;
        text-align: left;
        display: flex;
        align-items: center;
        gap: 12px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        cursor: pointer;
    }

    .mobile-auth-btn.login-btn {
        background: rgba(134, 176, 189, 0.1);
        color: var(--brand-primary);
        border: 1px solid rgba(134, 176, 189, 0.2);
    }

    .mobile-auth-btn.signup-btn {
        background: var(--brand-primary);
        color: white;
        box-shadow: 0 4px 12px rgba(134, 176, 189, 0.3);
    }

    .mobile-auth-btn.contact-btn {
        background: rgba(226, 161, 111, 0.1);
        color: var(--brand-secondary);
        border: 1px solid rgba(226, 161, 111, 0.2);
    }

    .mobile-auth-btn:hover {
        transform: translateY(-1px);
    }

    .mobile-auth-btn svg {
        width: 16px;
        height: 16px;
        opacity: 0.8;
    }

    /* Show mobile navigation elements on mobile */
    .main-nav .nav-footer,
    .main-nav .nav-social-links,
    .main-nav .nav-social-link {
        display: block !important;
    }

    .main-nav .nav-social-links {
        display: flex !important;
    }

    .main-nav .nav-social-link {
        display: flex !important;
    }

    /* Navigation Footer */
    .nav-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 16px 20px;
        border-top: 1px solid rgba(209, 211, 212, 0.2);
        background: rgba(250, 250, 250, 0.8);
        backdrop-filter: blur(10px);
        display: block !important;
    }

    .nav-footer-content {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .nav-social-links {
        display: flex;
        gap: 12px;
        justify-content: center;
    }

    .nav-social-link {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        background: rgba(134, 176, 189, 0.1);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--brand-primary);
        transition: all 0.3s ease;
    }

    .nav-social-link:hover {
        background: var(--brand-primary);
        color: white;
        transform: translateY(-2px);
    }

    .nav-copyright {
        text-align: center;
        font-size: 11px;
        color: var(--gray-500);
        margin-top: 8px;
    }

    /* Remove overlay for modern dropdown menu */
    .menu-overlay {
        display: none !important;
    }

    /* Mobile Artists Carousel */
    .artists-section {
        padding: 40px 0;
    }

    .artists-carousel-container {
        position: relative;
        padding: 0 16px;
    }

    .artists-carousel {
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px 0 16px;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    .artists-carousel::-webkit-scrollbar {
        height: 4px;
    }

    .artists-carousel::-webkit-scrollbar-track {
        background: rgba(134, 176, 189, 0.1);
        border-radius: 2px;
    }

    .artists-carousel::-webkit-scrollbar-thumb {
        background: var(--brand-primary);
        border-radius: 2px;
    }

    .artists-grid {
        display: flex;
        gap: 16px;
        padding: 0 4px;
        min-width: max-content;
    }

    .artist-card-home {
        flex: 0 0 280px;
        background: white;
        border-radius: 16px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
    }

    .artist-card-home:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 25px rgba(134, 176, 189, 0.15);
    }

    /* Hide navigation arrows on mobile */
    .carousel-nav {
        display: none;
    }

    /* Add scroll indicators */
    .artists-carousel-container::after {
        content: "Swipe to see more →";
        position: absolute;
        bottom: -8px;
        right: 20px;
        font-size: 12px;
        color: var(--gray-500);
        font-style: italic;
        opacity: 0.7;
    }
}

/* ===== MAIN CONTENT MOBILE OPTIMIZATIONS ===== */

@media (max-width: 767px) {
    .main-content {
        padding: calc(70px + 16px) 16px 60px;
        margin: 0;
    }

    /* Browse Layout */
    .browse-layout {
        display: block;
    }

    .filter-sidebar {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 70px);
        background: var(--white);
        z-index: 998;
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 20px;
        border-top: 1px solid var(--gray-200);
    }

    .filter-sidebar.active {
        left: 0;
    }

    .show-filters-btn {
        display: flex !important;
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: var(--brand-primary);
        color: white;
        border: none;
        border-radius: 50px;
        padding: 16px 20px;
        box-shadow: var(--shadow-lg);
        z-index: 1001;
        font-weight: 500;
    }

    .filter-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px 0;
        background: none;
        border: none;
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 20px;
    }

    /* Content Area */
    .content-area {
        padding: 0;
    }

    .top-controls {
        margin-bottom: 16px;
    }

    .search-section {
        margin-bottom: 20px;
    }

    .search-wrapper {
        margin-bottom: 16px;
    }

    .search-bar,
    .hero-search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 48px 14px 16px;
        height: 48px;
    }

    /* Quick Filters */
    .quick-filters {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .filter-chips {
        flex-wrap: wrap;
        gap: 8px;
    }

    .filter-chip {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 36px;
    }

    /* View Controls */
    .view-controls {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .left-controls,
    .right-controls {
        width: 100%;
    }

    .right-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .view-mode-toggle {
        order: 2;
    }

    .sort-options {
        order: 1;
    }

    .sort-options select {
        font-size: 16px;
        padding: 8px 12px;
        min-height: 40px;
    }
}

/* ===== GRID & CARDS MOBILE OPTIMIZATIONS ===== */

@media (max-width: 767px) {
    .samples-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .sample-card {
        padding: 16px;
        border-radius: var(--radius-lg);
    }

    .sample-card .waveform-container {
        height: 60px;
        margin: 12px 0;
    }

    .sample-card .sample-actions {
        flex-direction: column;
        gap: 8px;
        margin-top: 16px;
    }

    .sample-card .btn {
        width: 100%;
        justify-content: center;
    }

    /* List View Optimization */
    .samples-grid.list-view .sample-card {
        display: flex;
        flex-direction: column;
        height: auto !important;
        min-height: auto !important;
    }

    .samples-grid.list-view .sample-info {
        order: 1;
    }

    .samples-grid.list-view .waveform-container {
        order: 2;
        margin: 12px 0;
    }

    .samples-grid.list-view .sample-badges {
        order: 3;
        margin-bottom: 12px;
    }

    .samples-grid.list-view .sample-actions {
        order: 4;
    }
}

/* ===== MODAL MOBILE OPTIMIZATIONS ===== */

@media (max-width: 767px) {
    .modal {
        padding: 20px;
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-width: none;
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-header {
        padding: 20px 20px 16px;
        border-bottom: 1px solid var(--gray-200);
    }

    .modal-header h2 {
        font-size: 20px;
    }

    .auth-form,
    .project-form {
        padding: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 16px;
        min-height: 48px;
    }

    .form-actions {
        flex-direction: column;
        gap: 12px;
        padding-top: 20px;
    }

    .form-actions button {
        width: 100%;
        min-height: 48px;
    }
}

/* ===== FILTER SECTION MOBILE OPTIMIZATIONS ===== */

@media (max-width: 767px) {
    .filter-section {
        margin-bottom: 24px;
        border-bottom: 1px solid var(--gray-200);
        padding-bottom: 20px;
    }

    .filter-section:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .filter-section-header {
        padding: 16px 0;
    }

    .filter-section-header h3 {
        font-size: 18px;
    }

    .section-toggle {
        padding: 8px;
        min-height: 40px;
        min-width: 40px;
    }

    .filter-section-content {
        padding: 0;
    }

    .filter-options {
        gap: 16px;
    }

    .filter-option {
        padding: 12px 0;
        font-size: 16px;
        min-height: 44px;
    }

    .checkmark {
        width: 20px;
        height: 20px;
    }

    .filter-actions {
        padding: 20px 0 0;
        border-top: 1px solid var(--gray-200);
        margin-top: 20px;
    }

    .clear-filters {
        width: 100%;
        min-height: 48px;
        font-size: 16px;
    }
}

/* ===== FOOTER MOBILE OPTIMIZATIONS ===== */

@media (max-width: 767px) {
    .main-footer {
        padding: 40px 20px 20px;
    }

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

    .footer-section h3,
    .footer-section h4 {
        margin-bottom: 16px;
    }

    .footer-section ul {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .social-links {
        justify-content: center;
        gap: 20px;
        margin-top: 16px;
    }

    .social-links a {
        min-height: 44px;
        min-width: 44px;
        padding: 12px;
    }

    .footer-bottom {
        margin-top: 32px;
        padding-top: 20px;
        text-align: center;
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Reduce animations on mobile for better performance */
@media (max-width: 767px) {
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }

    .video-background video {
        display: none !important; /* Always hide video on mobile */
    }

    .hero-section {
        background-attachment: scroll; /* Fix iOS background-attachment issues */
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Focus styles for mobile */
@media (max-width: 767px) {
    button:focus,
    input:focus,
    select:focus,
    textarea:focus,
    a:focus {
        outline: 2px solid var(--brand-primary);
        outline-offset: 2px;
    }

    /* Skip to main content for screen readers */
    .skip-to-main {
        position: absolute;
        top: -40px;
        left: 6px;
        background: var(--brand-primary);
        color: white;
        padding: 8px;
        text-decoration: none;
        border-radius: 4px;
        z-index: 10000;
    }

    .skip-to-main:focus {
        top: 6px;
    }
}

/* ===== TABLET SPECIFIC OPTIMIZATIONS ===== */

@media (min-width: 768px) and (max-width: 1023px) {
    .header-content {
        padding: 0 24px;
    }

    .main-content {
        padding: calc(90px + 24px) 24px 60px;
    }

    .browse-layout {
        grid-template-columns: 280px 1fr;
        gap: 24px;
    }

    .samples-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 20px;
    }

    .filter-sidebar {
        position: static;
        height: auto;
    }

    .show-filters-btn {
        display: none !important;
    }

    /* Tablet navigation - keep desktop style */
    .main-nav {
        position: static;
        height: auto;
        background: transparent;
    }

    .nav-tabs {
        flex-direction: row;
        padding: 0 24px;
    }

    .mobile-menu-btn {
        display: none;
    }
}

/* ===== LANDSCAPE PHONE OPTIMIZATIONS ===== */

@media (max-width: 767px) and (orientation: landscape) {
    .hero-section {
        min-height: 400px;
        padding: 60px 0 40px;
    }

    .modal {
        align-items: center;
    }

    .modal-content {
        max-height: 80vh;
        border-radius: 16px;
    }

    .main-nav {
        height: calc(100vh - 70px);
    }

    .filter-sidebar {
        height: calc(100vh - 70px);
    }
}

/* ===== HIGH DPI DISPLAYS ===== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    .logo,
    .nav-tab,
    .btn {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ===== DARK MODE SUPPORT (if implemented) ===== */

@media (prefers-color-scheme: dark) {
    /* Future dark mode optimizations can go here */
}

/* ===== REDUCED MOTION SUPPORT ===== */

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

    .carousel-nav,
    .filter-section-content,
    .main-nav,
    .filter-sidebar {
        transition: none !important;
    }
}