/* ============ Mobile Responsiveness Fixes ============ */

/* Global Mobile Adjustments */
@media (max-width: 1024px) {
    .container {
        padding: 0 var(--space-md);
    }

    .dashboard-layout {
        grid-template-columns: 240px 1fr;
        gap: var(--space-lg);
    }
}

@media (max-width: 768px) {

    /* Navbar Tweaks */
    .nav-container {
        padding: 10px;
        flex-wrap: wrap;
    }

    .logo {
        font-size: 1.1rem;
    }

    .nav-links {
        display: none !important;
        /* Hide desktop links, use bottom nav */
    }

    .nav-right {
        gap: 10px;
    }

    /* Dashboard Layout */
    .dashboard-layout {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .dashboard-sidebar {
        width: 100%;
        position: static;
        padding: 15px;
        border-radius: var(--radius-md);
        margin-bottom: 20px;
        z-index: 10;
    }

    .profile-avatar-large {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 10px;
        gap: 10px;
        scroll-snap-type: x mandatory;
    }

    .nav-item {
        flex: 0 0 auto;
        border: 1px solid var(--border);
        white-space: nowrap;
        scroll-snap-align: start;
        padding: 8px 16px;
    }

    .dashboard-content {
        width: 100%;
    }

    /* Grid Stacking */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .listings-grid,
    .info-grid,
    .steps-container {
        grid-template-columns: 1fr;
    }

    .steps-container {
        gap: 30px;
    }

    /* Card Adjustments */
    .intro-card {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .intro-image {
        margin-top: 20px;
        display: flex;
        justify-content: center;
    }

    .intro-title {
        font-size: 1.5rem;
    }

    /* Listing Rows (Dashboard) */
    .listing-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .listing-row-thumb {
        width: 50px;
        height: 50px;
    }

    .listing-info {
        width: 100%;
    }

    .listing-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }

    .listing-actions .btn {
        flex: 1;
    }

    /* Matches Rows */
    .match-row {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }

    .match-thumb {
        width: 50px;
        height: 50px;
        margin-bottom: 10px;
    }

    .match-info h4 {
        font-size: 1rem;
    }

    .match-meta span {
        font-size: 0.8rem;
    }

    .match-actions {
        flex-direction: column;
        width: 100%;
    }

    .match-actions button {
        width: 100%;
        margin-top: 5px;
    }

    /* Detail Page Mobile */
    .detail-hero {
        padding: 15px;
        border-radius: var(--radius-lg);
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        padding: 15px;
    }

    .route-visual {
        flex-direction: column;
        align-items: center;
        gap: 30px;
        padding: 20px 0;
    }

    .route-line {
        width: 2px;
        height: 100%;
        left: 50%;
        top: 0;
        transform: translateX(-50%);
        background: repeating-linear-gradient(to bottom, var(--border) 0, var(--border) 10px, transparent 10px, transparent 20px);
    }

    .route-line::after {
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%) rotate(90deg);
    }

    .owner-card-premium {
        position: static;
        margin-top: 20px;
        padding: 20px;
    }

    .nav-right #authBlock {
        display: none;
        /* Hide top auth block on mobile, rely on bottom nav 'Profile' */
    }


    /* Ensure Bottom Nav is Visible */
    .mobile-bottom-nav {
        display: flex;
        z-index: 9999;
    }

    /* Adjust main content padding for bottom nav */
    main.main-content {
        padding-bottom: 70px;
    }

    /* ============ Admin Dashboard Mobile ============ */
    .admin-container {
        padding: 1rem;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .admin-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
        margin-bottom: 1.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .admin-tab {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    /* Make tables scrollable horizontally */
    .admin-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    .admin-table {
        min-width: 600px;
        /* Force minimum width to trigger scroll */
    }

    /* Adjust stats grid for very small screens */
    .stats-grid,
    .stats-grid-compact {
        grid-template-columns: 1fr;
        /* Full width cards */
        gap: 10px;
    }

    /* Chat layout on mobile */
    #messages-tab>div {
        flex-direction: column;
        height: calc(100vh - 200px);
    }

    #messages-tab>div>div:first-child {
        /* Sidebar */
        width: 100%;
        height: 150px;
        min-height: 150px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    /* Modals on Mobile */
    .modal-content {
        width: 95%;
        margin: 10px;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Auth Pages Mobile */
    .auth-card {
        padding: 1.5rem;
    }
}

/* Extra small devices */
@media (max-width: 380px) {
    .hero-stats-row {
        grid-template-columns: 1fr;
    }
}