/* responsive.css */

/* ── Global Variables for Responsive Breakpoints ── */
:root {
    --mobile-padding: 16px;
    --touch-target: 48px;
    --app-radius: 12px;
    --elevation-1: 0 2px 5px rgba(0,0,0,0.05);
    --elevation-2: 0 4px 12px rgba(0,0,0,0.1);
    --elevation-3: 0 8px 24px rgba(0,0,0,0.15);
}

/* =========================================================================
   MOBILE DEVICES (Up to 767px)
   ========================================================================= */
@media (max-width: 767px) {
    /* ── Typography & Spacing ── */
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
    h4 { font-size: 16px; }
    
    .container {
        padding-left: var(--mobile-padding);
        padding-right: var(--mobile-padding);
    }

    /* ── Header ── */
    .header {
        padding: 12px var(--mobile-padding);
    }
    .header-logo img {
        max-height: 32px !important;
    }
    .header-icons {
        gap: 12px;
    }
    .header-icons i {
        font-size: 20px;
    }
    
    /* ── Product Archive Layout ── */
    .archive-top-bar {
        flex-direction: column;
        align-items: stretch !important;
        padding: 12px var(--mobile-padding);
        gap: 12px;
    }
    
    .archive-top-bar > div:first-child {
        justify-content: space-between;
        width: 100%;
        order: 2; /* Results info below the buttons */
    }
    
    .archive-top-bar > div:last-child {
        width: 100%;
        display: flex;
        gap: 8px;
        order: 1; /* Buttons on top */
    }
    
    .mobile-filter-btn {
        flex: 1;
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 8px;
        height: 40px;
        border-radius: 8px;
        font-weight: 600;
        background: #f0f2f2;
        border: 1px solid var(--border-color);
        color: var(--text-primary);
    }
    
    .sort-select {
        flex: 1;
        height: 40px;
        width: 100%;
        border-radius: 8px;
        text-align: center;
        text-align-last: center; /* Centers text in select */
        appearance: none; /* Hide default arrow */
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 16px;
    }
    
    .results-info {
        font-size: 13px;
        width: 100%;
        text-align: center;
        color: var(--text-secondary);
    }

    .archive-container {
        padding: 0 var(--mobile-padding);
        margin-top: 12px;
    }
    
    .archive-sidebar-wrapper {
        display: none !important; /* Hide desktop sidebar completely */
    }
    
    .archive-main-content {
        padding-left: 0 !important;
    }

    /* ── Mobile Product Grid (EXACTLY 2 COLUMNS) ── */
    .product-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        margin-bottom: 24px;
    }
    
    .product-wrapper {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }
    
    .saas-card {
        border-radius: var(--app-radius);
    }
    
    .product-title-below {
        font-size: 13px !important;
        line-height: 1.4 !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .saas-price-tag {
        font-size: 16px !important;
        padding: 4px 8px !important;
    }
    
    /* ── Mobile Filter Drawer (Android Bottom Sheet Style) ── */
    #mobileFilterDrawer {
        height: 85vh !important;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
        bottom: 0;
        top: auto !important;
    }
    
    #mobileFilterDrawer .offcanvas-header {
        padding: 16px var(--mobile-padding);
        border-bottom: 1px solid #f0f0f0;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 10;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }
    
    #mobileFilterDrawer .offcanvas-title {
        font-size: 16px;
    }
    
    #mobileFilterDrawer .offcanvas-body {
        padding: var(--mobile-padding);
        padding-bottom: 80px; /* Space for footer */
    }
    
    #mobileFilterDrawer .offcanvas-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        padding: 12px var(--mobile-padding);
        border-top: 1px solid #f0f0f0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        z-index: 10;
    }
    
    /* Ensure filter inputs have good touch targets */
    .custom-checkbox label,
    .color-swatch,
    .size-button {
        min-height: 36px;
        display: flex;
        align-items: center;
        margin-bottom: 8px;
    }
    
    /* ── Sticky Bottom Action Bar for Product Single ── */
    .mobile-sticky-action-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        padding: 12px var(--mobile-padding);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 999;
        display: flex;
        gap: 12px;
    }
    
    .mobile-sticky-action-bar .btn,
    .mobile-sticky-action-bar .action-btn {
        flex: 1;
        height: var(--touch-target);
        border-radius: 24px;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 0;
    }
    
    /* Pad the bottom of the body when sticky bar is present */
    body:has(.mobile-sticky-action-bar) {
        padding-bottom: 80px;
    }

    /* ── Forms & Touch Targets ── */
    input.form-control,
    select.form-select,
    .btn {
        min-height: var(--touch-target);
        font-size: 16px; /* Prevents iOS zoom */
        border-radius: 8px;
    }
    
    /* ── Tables ── */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* ── Footer ── */
    .main-footer {
        padding-top: 32px;
        padding-bottom: 32px;
    }
    
    .footer-col {
        margin-bottom: 24px;
    }
    
    .footer-col h6 {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    /* ── Modals ── */
    .modal-dialog {
        margin: var(--mobile-padding);
    }
    .modal-content {
        border-radius: var(--app-radius);
    }
}

/* =========================================================================
   TABLET DEVICES (768px - 991px)
   ========================================================================= */
@media (min-width: 768px) and (max-width: 991px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .archive-sidebar-wrapper {
        display: none !important;
    }
    .archive-main-content {
        padding-left: 0 !important;
    }
    #mobileFilterDrawer {
        height: 70vh !important;
        bottom: 0;
        top: auto !important;
    }
}
