/* ============================================
   MATCHA - Responsive Design
   Mobile-first breakpoints for all devices
   ============================================ */

/* ============================================
   MOBILE MENU - Slide-down navigation panel
   ============================================ */
.mobile-menu {
    display: none;
    position: fixed;
    top: 4rem;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    z-index: 99;
    padding: 1.5rem;
    overflow-y: auto;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-bottom: 1px solid var(--border-color);
}

.mobile-menu.active {
    transform: translateY(0);
    opacity: 1;
}

.mobile-menu-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-menu-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    transition: background 0.2s ease;
}

.mobile-menu-nav a:hover {
    background: var(--bg-hover);
}

.mobile-menu-nav a svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.mobile-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mobile-menu-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 0.875rem;
    font-size: 1rem;
}

/* Hamburger X animation */
.mobile-menu-btn.active svg .line-1 {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active svg .line-2 {
    opacity: 0;
}

.mobile-menu-btn.active svg .line-3 {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Body lock when menu is open */
body.mobile-menu-open {
    overflow: hidden;
}

/* Theme/Language controls inside mobile menu */
.mobile-menu-controls {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.mobile-menu-controls button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-menu-controls button:hover,
.mobile-menu-controls button:active {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}


/* ============================================
   TABLET BREAKPOINT (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {

    /* Prevent horizontal scroll */
    html,
    body {
        overflow-x: hidden;
    }

    /* Container */
    .container {
        padding: 0 1.25rem;
    }

    /* Typography */
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.625rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Hero */
    .hero {
        padding: 3rem 0;
        min-height: auto;
    }

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

    .hero p {
        font-size: 1.1rem;
    }

    .hero-content {
        max-width: 700px;
    }

    /* Choice Cards */
    .choice-card {
        padding: 1.5rem;
    }

    .choice-card-icon {
        width: 50px;
        height: 50px;
    }

    .choice-card-content h2 {
        font-size: 1.25rem;
    }

    /* Section spacing */
    .py-16 {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }

    .py-12 {
        padding-top: 2.5rem;
        padding-bottom: 2.5rem;
    }

    /* Profile header */
    .profile-header {
        padding: 1.5rem;
    }

    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    /* Footer */
    .footer {
        padding: 3rem 0 1.5rem;
        margin-top: 3rem;
    }

    /* Project detail layout */
    .project-detail-grid {
        grid-template-columns: 1fr;
    }

    /* Chat */
    .chat-container {
        grid-template-columns: 280px 1fr;
    }

    /* Offer cards */
    .offer-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .offer-price {
        text-align: left;
    }

    /* Steps (How It Works) */
    .grid.md\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ============================================
   MOBILE BREAKPOINT (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {

    /* Show mobile menu panel */
    .mobile-menu {
        display: block;
    }

    /* Hide desktop nav + actions on mobile */
    .navbar-nav {
        display: none !important;
    }

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

    /* Navbar sizing */
    .navbar-inner {
        height: 3.5rem;
    }

    .navbar-brand {
        font-size: 1.25rem;
    }

    .navbar-brand svg {
        width: 26px;
        height: 26px;
    }

    .navbar-actions {
        gap: 0.25rem;
    }

    /* Hide preference group and separators on mobile - they're in the hamburger menu */
    .nav-group-prefs,
    .nav-separator {
        display: none !important;
    }

    /* Compact logged-in nav for mobile */
    #logged-in-nav {
        gap: 0.125rem !important;
    }

    #logged-in-nav .nav-icon {
        padding: 0.3rem;
    }

    #logged-in-nav .nav-icon svg {
        width: 20px;
        height: 20px;
    }

    #logged-in-nav .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }

    /* Hide some navbar items on mobile, now in mobile menu */
    #logged-out-nav {
        display: none !important;
    }

    /* Mobile menu top offset */
    .mobile-menu {
        top: 3.5rem;
    }

    /* Container */
    .container {
        padding: 0 1rem;
    }

    /* Typography */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.375rem;
    }

    h3 {
        font-size: 1.125rem;
    }

    h4 {
        font-size: 1rem;
    }

    /* Hero */
    .hero {
        padding: 2.5rem 0;
    }

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

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

    .welcome-badge {
        font-size: 0.8125rem;
        padding: 0.375rem 0.875rem;
    }

    /* Choice cards  */
    .choice-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .choice-card {
        padding: 1.25rem;
    }

    .choice-card-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 1rem;
    }

    .choice-card-icon svg {
        width: 24px;
        height: 24px;
    }

    .choice-card-content h2 {
        font-size: 1.125rem;
    }

    .choice-card-content p {
        font-size: 0.9375rem;
    }

    .choice-card-arrow {
        width: 36px;
        height: 36px;
        top: 1.25rem;
        right: 1.25rem;
    }

    /* Section spacing */
    .py-16 {
        padding-top: 2.5rem;
        padding-bottom: 2.5rem;
    }

    .py-12 {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .py-8 {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .mb-8 {
        margin-bottom: 1.5rem;
    }

    .mt-8 {
        margin-top: 1.5rem;
    }

    /* Section header */
    .section-header {
        margin-bottom: 1rem;
    }

    .section-header h2 {
        font-size: 1.25rem;
    }

    /* Categories grid */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .category-card {
        padding: 1rem;
    }

    .category-card-icon {
        width: 48px;
        height: 48px;
    }

    .category-card-icon svg {
        width: 24px;
        height: 24px;
    }

    /* Projects / Ads grid */
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Cards */
    .card-body {
        padding: 1rem;
    }

    .card-footer {
        padding: 0.75rem 1rem;
    }

    .card-title {
        font-size: 1rem;
    }

    /* Profile */
    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 1.25rem;
    }

    .profile-avatar {
        width: 72px;
        height: 72px;
        font-size: 1.75rem;
    }

    .profile-info h1 {
        font-size: 1.375rem;
    }

    .profile-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .profile-tab {
        white-space: nowrap;
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }

    /* ===== CHAT - Mobile toggle between list and conversation ===== */
    .chat-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 3.5rem);
        position: relative;
    }

    /* Sidebar: visible by default on mobile (chat list view) */
    .chat-sidebar {
        display: flex;
        position: fixed;
        top: 3.5rem;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        background: var(--bg-card);
    }

    /* Hide sidebar when a chat is open */
    .chat-sidebar.mobile-hidden {
        display: none !important;
    }

    /* Chat main: hidden by default on mobile */
    .chat-main {
        display: none;
    }

    /* Show chat main when active */
    .chat-main.mobile-active {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 3.5rem;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        background: var(--bg-card);
        overflow: hidden;
    }

    /* Back button - only visible on mobile */
    .chat-back-btn {
        display: flex !important;
        align-items: center;
        gap: 0.25rem;
        background: none;
        border: none;
        color: var(--primary);
        cursor: pointer;
        padding: 0.5rem;
        border-radius: var(--radius);
        font-size: 0.875rem;
        font-weight: 500;
        flex-shrink: 0;
        transition: background 0.2s ease;
    }

    .chat-back-btn:hover {
        background: var(--bg-hover);
    }

    .chat-back-btn svg {
        width: 20px;
        height: 20px;
    }

    .chat-message {
        max-width: 85%;
    }

    .chat-messages {
        padding: 1rem;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }

    .chat-input {
        padding: 0.75rem 1rem;
    }

    .chat-header {
        padding: 0.75rem 1rem;
        overflow: hidden;
        max-width: 100%;
    }

    .chat-header-info h3 {
        font-size: 0.95rem;
    }

    .chat-header-info span {
        font-size: 0.8rem;
    }

    /* Auth pages */
    .auth-page {
        padding: 1rem;
    }

    .auth-card {
        max-width: 100%;
        border-radius: var(--radius-lg);
    }

    .auth-header {
        padding: 1.5rem 1.5rem 1rem;
    }

    .auth-header h1 {
        font-size: 1.25rem;
    }

    .auth-body {
        padding: 0 1.5rem 1.5rem;
    }

    .user-type-options {
        grid-template-columns: 1fr;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }

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

    textarea.form-control {
        min-height: 100px;
    }

    /* Buttons - touch friendly */
    .btn {
        padding: 0.875rem 1.25rem;
        min-height: 44px;
    }

    .btn-sm {
        padding: 0.625rem 1rem;
        min-height: 40px;
    }

    .btn-lg {
        padding: 1rem 1.5rem;
    }

    /* Modal */
    .modal {
        width: calc(100% - 1rem);
        max-height: calc(100vh - 2rem);
        border-radius: var(--radius-lg);
    }

    .provider-modal {
        max-width: 100%;
    }

    .modal-header {
        padding: 1rem 1.25rem;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .provider-option {
        padding: 1rem;
    }

    .provider-option-icon {
        width: 40px;
        height: 40px;
    }

    /* Offers */
    .offer-card {
        padding: 1rem;
    }

    .offer-meta {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .offer-actions {
        flex-direction: column;
    }

    .offer-actions .btn {
        width: 100%;
    }

    /* Footer */
    .footer {
        padding: 2.5rem 0 1.5rem;
        margin-top: 2rem;
    }

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

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }

    /* Toast */
    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        max-width: 100%;
    }

    /* Search box */
    .search-box {
        flex-direction: column;
    }

    /* Filter sidebar */
    .filter-sidebar {
        margin-bottom: 1rem;
    }

    /* How it works steps */
    .grid.md\:grid-cols-3 {
        grid-template-columns: 1fr;
    }

    /* CTA section */
    .text-center .btn-lg {
        width: 100%;
    }

    /* User dropdown */
    .user-dropdown {
        position: fixed;
        top: 3.5rem;
        left: 1rem;
        right: 1rem;
        min-width: auto;
    }

    /* Step icons */
    .step-icon {
        width: 64px !important;
        height: 64px !important;
    }

    .step-icon svg {
        width: 30px !important;
        height: 30px !important;
    }

    /* Page header search */
    .page-header-search {
        flex-direction: column;
    }

    /* Checkbox grid */
    .checkbox-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}


/* ============================================
   SMALL MOBILE (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {

    /* Container */
    .container {
        padding: 0 0.75rem;
    }

    /* Typography */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

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

    .hero p {
        font-size: 0.9375rem;
    }

    /* Categories - single column on very small */
    .categories-grid {
        grid-template-columns: 1fr;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Card meta */
    .card-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.375rem;
    }

    /* Section spacing */
    .py-16 {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .py-12 {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    /* Choice card compact */
    .choice-card {
        padding: 1rem;
    }

    .choice-card-content h2 {
        font-size: 1rem;
    }

    .choice-card-examples {
        font-size: 0.8125rem;
    }

    /* Offer */
    .offer-user {
        flex-direction: column;
        text-align: center;
    }

    /* Modal */
    .modal {
        width: calc(100% - 0.5rem);
    }

    /* Auth */
    .auth-header {
        padding: 1.25rem 1rem 0.75rem;
    }

    .auth-body {
        padding: 0 1rem 1.25rem;
    }

    .auth-header .logo {
        font-size: 1.5rem;
    }
}


/* ============================================
   LANDSCAPE PHONE FIXES
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 2rem 0;
    }

    .modal {
        max-height: 95vh;
    }

    .auth-page {
        padding: 0.5rem;
    }
}


/* ============================================
   TOUCH IMPROVEMENTS
   ============================================ */
@media (hover: none) and (pointer: coarse) {

    /* Remove hover effects on touch */
    .card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .category-card:hover {
        transform: none;
    }

    .choice-card:hover {
        transform: none;
    }

    /* Larger touch targets */
    .footer-links a {
        padding: 0.5rem 0;
        display: block;
    }

    .navbar-nav a {
        padding: 0.5rem 0.25rem;
    }

    /* Active states instead of hover */
    .btn:active {
        transform: scale(0.97);
    }

    .card:active {
        transform: scale(0.99);
    }

    .choice-card:active {
        transform: scale(0.98);
    }
}


/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .navbar,
    .footer,
    .mobile-menu,
    .toast-container,
    .modal-backdrop,
    .modal {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .container {
        max-width: 100%;
    }
}