/* --- dashboard-responsive.css (Final & Definitive Mobile Fix) --- */

.overlay, .mobile-toggle {
    display: none;
}
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(17, 24, 39, 0.6); backdrop-filter: blur(4px);
    z-index: 998; opacity: 0; visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
}
.overlay.is-visible {
    opacity: 1; visibility: visible;
}

/* === Tablet Breakpoint (1200px and below) === */
@media (max-width: 1200px) {
    .header-left-section .mobile-toggle { display: flex; }
    .main-content { padding-left: 0; padding-right: 0; }
    .left-sidebar {
        position: fixed; z-index: 1001;
        transform: translateX(-100%);
        transition: transform .3s ease-in-out;
        box-shadow: 0 0 25px rgba(0,0,0,0.1);
    }
    .left-sidebar.is-open { transform: translateX(0); }
}


/* === Mobile Breakpoint (768px and below) === */
@media (max-width: 768px) {
    /* --- 1. General Mobile Layout & Overflow Fix --- */
    .main-content { height: calc(100vh - var(--header-height)); }
    .dashboard-wrapper {
        padding: 1rem; gap: 1.5rem; width: 100%;
        max-width: 100vw; overflow-x: hidden;
    }
    
    /* --- 2. Header and Layout Stacking --- */
    .dashboard-header { padding: 0 1rem; }
    .logo-container h1 { display: none; }
    .header-nav.right-nav { gap: 0.5rem; }
    .left-sidebar { width: 280px; }
    .dashboard-grid.top-grid, .dashboard-grid.bottom-grid, .action-cards-grid {
        grid-template-columns: 1fr;
    }
    .service-grid { grid-template-columns: repeat(2, 1fr); }
    .profile-header-card { flex-direction: column; align-items: flex-start; padding: 1.5rem; }
    .last-submission-summary {
        border-left: none; border-top: 1px solid var(--border-color);
        padding-left: 0; padding-top: 1.5rem; margin-top: 1.5rem; width: 100%;
    }
    .popup-content.modern { width: 95%; }

    /* ============================================================== */
    /* === PURE CSS FIX: SIMPLIFY LISTS TO PREVENT OVERFLOW         === */
    /* ============================================================== */
    
    /* A. Hide the desktop headers. */
    .project-list-header, .cost-list-header {
        display: none;
    }

    /* B. Redefine the list items for a simplified mobile view. */
    .project-list-item, .cost-list-item {
        display: grid; /* Use grid for precise alignment */
        align-items: center;
        padding: 1rem;
        margin-bottom: 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        gap: 1rem;
    }

    /* C. HIDE NON-ESSENTIAL DETAILS on mobile to save space. */
    .project-list-item span:nth-of-type(2), /* Hides "Form Type" */
    .project-list-item span:nth-of-type(3), /* Hides "Date" */
    .cost-list-item span:nth-of-type(2),    /* Hides "Form Type" */
    .cost-list-item span:nth-of-type(3) {   /* Hides "Status" */
        display: none;
    }

    /* D. Remove the annoying underline (border) from all spans. */
    .project-list-item span, .cost-list-item span {
        border-bottom: none;
        padding: 0;
    }

    /* E. Define a simple 2-column layout for the "All Submissions" list. */
    .project-list-item {
        grid-template-columns: 1fr auto; /* ID on left, Status badge on right */
    }

    /* F. Define a 3-column layout for the "Billing Overview" list. */
    .cost-list-item {
        grid-template-columns: 1fr auto auto; /* ID | Total | Pending */
    }

    /* G. Style the remaining cost values to be clear. */
    .cost-list-item span:nth-of-type(4),
    .cost-list-item span:nth-of-type(5) {
        font-weight: 600;
        text-align: right;
    }

    /* H. Fix the summary total row on mobile. */
    .cost-list-summary {
        display: grid;
        grid-template-columns: 1fr auto;
        padding: 1rem;
    }
    .cost-list-summary .summary-label {
        grid-column: 1 / -1; /* Make "Totals:" span the full width */
        text-align: left;
        margin-bottom: 0.5rem;
        color: var(--text-secondary);
    }
    .cost-list-summary .summary-value {
        font-size: 1.1em;
        text-align: right;
    }
    /* Place total cost on the left, pending on the right */
    .cost-list-summary .summary-value:nth-of-type(1) { text-align: left; }
    .cost-list-summary .summary-value:nth-of-type(2) { text-align: right; }
    
    /* Dark Theme compatibility for the new layout */
    :root.dark-theme .project-list-item,
    :root.dark-theme .cost-list-item {
        border-color: var(--border-color);
    }
}