/* ============================================================
   Agent Portal Mobile Optimization CSS
   ============================================================ */

/* Global Mobile Styles */
@media (max-width: 768px) {
    /* Layout Adjustments */
    .main {
        padding: 1rem 0.75rem 5.5rem !important; /* Extra bottom padding for bottom nav */
    }
    
    .footer {
        margin-bottom: 4.5rem; /* Space for bottom nav */
        padding: 1rem;
        font-size: 0.75rem;
    }

    /* Page Header */
    .page-header {
        margin-bottom: 1.25rem !important;
    }
    .page-header__title {
        font-size: 1.35rem !important;
        flex-wrap: wrap;
        gap: 0.25rem 0.5rem;
    }
    .page-header__subtitle {
        font-size: 0.8rem;
        line-height: 1.5;
        margin-top: 0.25rem;
    }

    /* Filter Card */
    .card {
        margin-bottom: 1rem !important;
    }
    .card__header {
        padding: 0.85rem 1rem !important;
    }
    .card__title {
        font-size: 0.95rem !important;
    }
    #dateFilterForm > div {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    #dateFilterForm .form-group {
        min-width: 100% !important;
    }
    #dateFilterForm div[style*="margin-right: auto"] {
        margin-right: 0 !important;
        width: 100%;
    }
    #dateFilterForm .btn {
        width: 100%;
        justify-content: center;
        height: 46px !important;
        font-weight: 700;
    }

    /* Stats Row (Grid) */
    .stats-row {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
        margin-bottom: 1.25rem !important;
    }
    .stat-card {
        padding: 0.75rem !important;
        gap: 0.5rem !important;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .stat-card__icon {
        width: 42px !important;
        height: 42px !important;
        font-size: 1.2rem !important;
        border-radius: 8px !important;
    }
    .stat-card__value {
        font-size: 1.25rem !important;
    }
    .stat-card__label {
        font-size: 0.7rem !important;
        line-height: 1.4;
    }
    /* Make total progress card full width if odd */
    .stats-row > div:nth-child(4) {
        grid-column: span 2;
        flex-direction: row;
        text-align: right;
        justify-content: center;
    }
    .stats-row > div:nth-child(4) .stat-card__icon {
        margin-left: 0.5rem;
    }

    /* Data Table to Responsive Cards */
    .table-wrap {
        border: none !important;
        overflow-x: visible !important;
    }
    .data-table {
        display: block;
        width: 100%;
        border: none !important;
    }
    .data-table thead {
        display: none !important; /* Hide column headers on mobile */
    }
    .data-table tbody {
        display: block;
        width: 100%;
    }
    .data-table tbody tr {
        display: block;
        background: var(--color-bg-card);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        margin-bottom: 1rem;
        padding: 0.5rem 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        transition: transform 0.2s;
    }
    .data-table tbody tr:hover td {
        background: transparent !important;
    }
    .data-table td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 0.65rem 1rem !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
        text-align: left !important;
        font-size: 0.85rem !important;
    }
    html[data-theme="light"] .data-table td {
        border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    }
    .data-table td:last-child {
        border-bottom: none !important;
    }
    /* Cell data labels */
    .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--color-text-secondary);
        font-size: 0.75rem;
        text-align: right;
        margin-left: 1rem;
        white-space: nowrap;
    }
    /* Align values correctly */
    .data-table td > * {
        text-align: left;
        max-width: 70%;
    }
    
    /* Make full row content full width without flex spacing */
    .data-table td.actions, .data-table td[data-label="عملیات"], .data-table td[data-label="وضعیت ثبت"] {
        justify-content: center !important;
    }
    .data-table td.actions::before, .data-table td[data-label="عملیات"]::before {
        display: none !important;
    }
    
    /* Bigger touch buttons */
    .data-table .actions {
        width: 100% !important;
        max-width: 100% !important;
        justify-content: center;
        gap: 0.75rem !important;
        padding: 0.25rem 0;
    }
    .data-table .btn-sm {
        height: 42px !important;
        width: 42px !important;
        font-size: 1.1rem !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        border-radius: 8px !important;
    }

    /* Form submissions sticky bar */
    form > div[style*="justify-content: flex-end"] {
        position: fixed !important;
        bottom: 56px; /* Just above bottom nav */
        left: 0;
        right: 0;
        z-index: 90;
        margin-bottom: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.25);
        padding: 0.75rem 1rem !important;
        background: rgba(15, 23, 42, 0.9) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        display: flex;
        gap: 0.5rem !important;
    }
    html[data-theme="light"] form > div[style*="justify-content: flex-end"] {
        background: rgba(255, 255, 255, 0.9) !important;
    }
    form > div[style*="justify-content: flex-end"] button {
        flex: 1;
        height: 44px !important;
        justify-content: center;
        font-size: 0.9rem !important;
    }

    /* Fixed width input inputs inside daily-stats cards */
    .input-meter-value {
        max-width: 100% !important;
        width: 140px;
        height: 38px;
    }
    .select-obstacle {
        max-width: 100% !important;
        width: 160px;
        height: 38px;
    }

    /* Sidebar logic for inspection images */
    .gallery-layout {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    .subscriber-sidebar {
        position: static !important;
        max-height: none !important;
    }
    .subscriber-list-wrap {
        max-height: 250px !important;
    }

    /* Modal overlays adaptation */
    .modal {
        width: 95% !important;
        padding: 1.25rem !important;
        margin: 10px;
    }
    #mapContainer {
        height: 300px !important;
    }
    
    /* Login styling on mobile */
    .login-container {
        padding: 1rem !important;
    }
    .login-card {
        padding: 1.5rem 1.25rem !important;
    }
    .login-title {
        font-size: 1.3rem !important;
    }
    .login-actions .btn {
        height: 48px !important;
    }
}

/* ============================================================
   BOTTOM NAVIGATION BAR (MOBILE ONLY)
   ============================================================ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 999;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

html[data-theme="light"] .bottom-nav {
    background: rgba(255, 255, 255, 0.95);
    border-top-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-nav__container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 0.5rem;
}

.bottom-nav__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    transition: color 0.2s;
    gap: 3px;
}

.bottom-nav__link i {
    font-size: 1.15rem;
    transition: transform 0.2s;
}

.bottom-nav__link:active i {
    transform: scale(0.9);
}

.bottom-nav__link.active {
    color: var(--color-primary);
}

/* Show bottom nav on mobile */
@media (max-width: 768px) {
    .bottom-nav {
        display: block;
    }
    
    .topbar-desktop-user {
        display: none !important;
    }
    
    .mobile-user-drawer-info {
        display: flex !important;
        align-items: center;
        gap: 0.75rem;
        padding: 1rem 0.75rem;
        border-bottom: 1px solid var(--color-border);
        margin-bottom: 1rem;
        background: rgba(255, 255, 255, 0.03);
        border-radius: var(--radius-md);
        text-align: right;
    }
    html[data-theme="light"] .mobile-user-drawer-info {
        background: rgba(0, 0, 0, 0.02);
    }
    
    .mobile-user-drawer-info i {
        font-size: 2rem;
        color: var(--color-primary);
    }
    
    .mobile-user-drawer-info div {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    
    .mobile-user-drawer-info span {
        font-size: 0.7rem;
        color: var(--color-text-muted);
    }
    
    .mobile-user-drawer-info strong {
        font-size: 0.85rem;
        color: var(--color-text-primary);
    }

    .topbar__nav-link.logout-link {
        display: flex !important;
        margin-top: auto;
        color: #ef4444 !important;
        background: rgba(239, 68, 68, 0.06);
        border: 1px solid rgba(239, 68, 68, 0.2);
    }
    .topbar__nav-link.logout-link:hover {
        background: rgba(239, 68, 68, 0.15) !important;
    }
}

.mobile-user-drawer-info {
    display: none;
}

.topbar__nav-link.logout-link {
    display: none;
}

