/* Layout and major region rules: header, containers, sidebar, results */

/* Header */
.app-header {
    background-color: var(--primary);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 50; 
    position: relative;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 { font-size: 1.5rem; display: flex; align-items: center; gap: 0.5rem; margin: 0; }

.quote-btn {
    background-color: white;
    color: var(--primary);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.quote-btn:hover {
    background-color: #f7fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

/* Quote Count Badge */
.count-badge {
    background-color: var(--secondary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

.mobile-filter-btn {
    display: none; /* Hidden on Desktop */
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Layout */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden; 
    position: relative;
}

/* Sidebar (Desktop Default) */
.filters-sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.3s ease;
}

.sidebar-mobile-header { display: none; } 
.mobile-only { display: none; }

.filter-header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 1.5rem 0.5rem; }
.filter-header h2 { font-size: 1.1rem; color: var(--secondary); font-weight: 700; margin: 0; }
.text-btn { background: none; border: none; color: var(--primary); cursor: pointer; text-decoration: underline; font-size: 0.9rem; padding: 0;}

.filter-scroll-area {
    padding: 1rem 1.5rem 1.5rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.filter-group label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.5rem; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.filter-group select, .filter-group input[type="text"], .filter-group input[type="number"] {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border 0.2s;
}
.filter-group input:focus { border-color: var(--primary); outline: none; }

.filter-section-highlight {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    padding: 1rem;
    border-radius: 8px;
}

.toggle-group {
    display: flex;
    background: var(--bg-light);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.toggle-group input { display: none; }
.toggle-group label {
    flex: 1;
    text-align: center;
    padding: 8px;
    margin: 0;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--text-light);
}
.toggle-group input:checked + label {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Range & check visuals */
input[type=range] { width: 100%; accent-color: var(--primary); cursor: pointer; }
.checkbox-list { display: flex; flex-direction: column; gap: 0.75rem; }
.checkbox-item { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; font-weight: normal; font-size: 0.95rem; }
.checkbox-item input { accent-color: var(--primary); width: 1.1rem; height: 1.1rem; }

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 30;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s;
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* Main Results Area */
.results-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background-color: var(--bg-light);
    position: relative;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.view-toggles { display: flex; }
.view-btn {
    padding: 0.6rem 1.2rem;
    background: white;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-light);
    display: flex; align-items: center; gap: 0.5rem;
}
.view-btn:first-child { border-radius: 6px 0 0 6px; }
.view-btn:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.view-btn.active { background: var(--secondary); color: white; border-color: var(--secondary); }

/* Grid View placeholder */
.printers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding-bottom: 80px;
}

/* Right Quote Sidebar */
.quote-sidebar {
    width: 400px;
    background: white;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.3s ease;
}

.quote-sidebar.hidden { transform: translateX(100%); }

.quote-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.quote-sidebar-header h2 { font-size: 1.2rem; color: var(--secondary); font-weight: 700; margin: 0; }

#quote-iframe { flex: 1; }

/* Sidebar Mode / Full Page overrides */
body.sidebar-mode .app-header,
body.sidebar-mode .request-header,
body.sidebar-mode .order-summary,
body.sidebar-mode #checkout-form { display: none !important; }

body.sidebar-mode #checkout-btn {
    display: inline-block !important;
    width: calc(100% - 3rem);
    margin: 1rem 1.5rem;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: calc(100% - 2rem);
    margin: 0 1rem 1rem 1rem;
    padding: 0.75rem 1.5rem;
}

body:not(.sidebar-mode) #checkout-btn { display: none !important; }

body.sidebar-mode .cart-items-container { padding: 1rem !important; padding-bottom: 120px; }
body.sidebar-mode .cart-items-container h3 { font-size: 1rem; margin-bottom: 0.75rem; }
body.sidebar-mode .cart-items-summary > div { padding: 0.75rem !important; margin-bottom: 0.5rem !important; }
body.sidebar-mode .cart-items-summary h4 { font-size: 0.95rem; margin: 0 0 0.25rem 0 !important; }
body.sidebar-mode .cart-items-summary p { font-size: 0.85rem !important; }


/* ========================================= */
/*           MOBILE RESPONSIVENESS           */
/* ========================================= */

@media (max-width: 768px) {
    /* 1. Header */
    body { height: auto !important; }
    .app-header { 
        padding: 0.75rem 1rem; 
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    .header-content h1 { 
        font-size: 1.1rem; 
        white-space: nowrap; 
        overflow: hidden; 
        text-overflow: ellipsis; 
    }
    
    /* Toggle Button Visible */
    .mobile-filter-btn { display: block; }

    /* Quote Button Compact */
    .quote-btn { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
    .quote-btn span:not(#quote-count) { display: none; } /* Hide "Request" text if needed, or keep tailored */
    @media (max-width: 400px) {
        .quote-btn { padding: 0.4rem; }
        .quote-btn span:first-child { display: none; } /* Only show icon/count */
    }

    /* 2. Layout & Sidebar (Moved to Top) */
    .app-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .filters-sidebar {
        position: static;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        box-shadow: none;
        z-index: 10;
        
        /* Collapsed by default */
        display: none;
        transform: none; /* Reset desktop slide */
    }

    .filters-sidebar.active {
        display: flex; /* Expand */
        animation: expandDown 0.3s ease-out;
    }

    .sidebar-mobile-header { display: none; } /* Not needed in top-flow */
    .sidebar-overlay { display: none !important; } /* No overlay */
    
    .filter-scroll-area {
        padding: 1rem;
        max-height: 60vh; /* Scroll internally if too long */
    }
    
    .mobile-only { display: block; margin-top: 1rem; }

    /* 3. Main Content */
    .results-area { padding: 1rem; overflow: visible; }
    .desktop-only { display: none; }
    .results-header { flex-wrap: wrap; gap: 1rem; }

    /* 4. Grid */
    .printers-grid { 
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); 
        gap: 1rem; 
        padding-bottom: 100px; 
    }
    
    /* 5. Components */
    .wiz-options-grid { grid-template-columns: 1fr !important; }
    
    .compare-dock {
        width: 94%;
        bottom: 15px;
        padding: 0.75rem;
        flex-direction: column;
        gap: 0.75rem;
    }
    .dock-content, .dock-actions { width: 100%; justify-content: space-between; gap: 0; }
    .dock-btn { flex: 1; text-align: center; margin: 0 4px; }
    
    .card-actions button { padding: 12px; } /* Touch targets */
    .compare-toggle-btn { padding: 8px 12px; }
}

@keyframes expandDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* --- Header Mobile Fixes --- */
@media (max-width: 768px) {
    .header-content {
        gap: 0.5rem; /* Reduce gap between title and actions */
    }
    
    .header-content h1 {
        font-size: 1rem; /* Smaller title */
        margin-right: auto; /* Push actions to right */
        flex: 1; /* Allow shrinking */
        min-width: 0; /* Enable ellipsis */
    }
    
    .header-content > div {
        flex-shrink: 0; /* Prevent buttons from shrinking */
        gap: 0.5rem !important; /* Tighter button gap */
    }
    
    .mobile-filter-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 380px) {
    /* On tiny screens, hide title icon or text if needed, 
       but currently ellipsis should handle it. 
       Let's ensure buttons fit. */
    .header-content h1 span { display: none; } /* Hide 'Device Options' text? No, keep it but let it truncate. */
    .header-content h1 i { display: none; } /* Hide icon to save space */
}


/* --- Quote Sidebar Mobile Sheet --- */
@media (max-width: 768px) {
    .quote-sidebar {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 85vh; /* Large sheet */
        z-index: 2500;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.15);
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: 20px 20px 0 0;
        transform: translateY(100%); /* Hide at bottom */
        transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    .quote-sidebar:not(.hidden) {
        transform: translateY(0); /* Slide up */
    }
}


/* Flash Animation for View Request Button */
@keyframes flashHighlight {
    0% { background-color: white; transform: scale(1); }
    50% { background-color: #ffd700; transform: scale(1.1); box-shadow: 0 0 15px #ffd700; }
    100% { background-color: white; transform: scale(1); }
}

.flash-highlight {
    animation: flashHighlight 0.6s ease-in-out;
}

