/* ========================================================
   SOUTHDEV HOME DEPOT – Responsive Breakpoints
   ======================================================== */

/* ---------- Tablet Landscape / Small Desktop ---------- */
@media (max-width: 1200px) {
    .product-grid { grid-template-columns: repeat(3, 1fr); }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .chart-grid { grid-template-columns: 1fr; }
    .dashboard-grid-3 { grid-template-columns: 1fr 1fr; }
    .checkout-grid { grid-template-columns: 1fr; }
}

/* ---------- Tablet Portrait ---------- */
@media (max-width: 992px) {
    /* Sidebar collapses to overlay */
    .sidebar {
        transform: translateX(-100%);
        z-index: 260;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0,0,0,.3);
    }
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(28,28,28,.5);
        z-index: 240;
    }
    .sidebar-backdrop.active { display: block; }

    /* Ensure top-bar stays clickable above the backdrop */
    .top-bar { z-index: 250; }

    .main-content { margin-left: 0 !important; }
    .top-bar .sidebar-toggle { display: flex; }

    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .product-detail { grid-template-columns: 1fr; gap: 24px; }
    .product-detail .product-gallery img { height: 350px; }
    .pd-grid { grid-template-columns: 1fr; gap: 24px; }
    .pd-gallery__img { height: 380px; }
    .pd-reviews__summary { flex-direction: column; gap: 20px; align-items: flex-start; }
    .pd-reviews__list { grid-template-columns: 1fr 1fr; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    
    /* Tablet-specific product-card adjustments */
    .product-card .product-img { height: 200px; }
    .product-card .product-info { padding: 10px; }
    .product-card .product-name { font-size: 14px; }
    .product-card .product-price { font-size: 16px; }
    .btn-add-cart { width: calc(100% - 24px); margin: 10px 12px; }

    .dashboard-grid-2 { grid-template-columns: 1fr; }
    .dashboard-grid-3 { grid-template-columns: 1fr; }

    /* Navbar responsive */
    .navbar .nav-links { display: none; }
    .navbar .mobile-toggle { display: flex; }
    /* Also support site-header mobile toggle (two-row header) */
    .site-header .topbar-inner { position: relative; }
    .site-header .mobile-toggle { display: flex; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); z-index: 120; background: transparent; border-color: rgba(255,255,255,.18); color: #fff; }
    .site-header .mobile-toggle i { color: #fff; }
    .navbar .nav-links.mobile-open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 64px;
        left: 0; right: 0;
        background: var(--white);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        padding: 8px 0;
        z-index: 90;
    }
    .navbar .nav-links.mobile-open a {
        padding: 12px 24px;
    }

    /* Place hamburger inside left edge and give the navbar content left padding to avoid overlap */
    .navbar .mobile-toggle { left: 12px; right: auto; top: 50%; transform: translateY(-50%); z-index: 120; position: absolute; }
    .navbar .container { padding-left: 56px; }

    .hero { padding: 50px 0; }
    .hero h1 { font-size: 32px; }
    .category-bar { top: 56px; }
    .page-content { padding: 20px 16px; }
    .top-bar { padding: 0 16px; }
    .data-table-header { padding: 14px 16px; }
    .data-table th,
    .data-table td { padding: 12px 14px; }
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
    .container { padding: 0 16px; }

    .footer-grid { grid-template-columns: 1fr; }
    .footer-bottom { flex-direction: column; align-items: flex-start; }

    /* Denser product cards: larger images, tighter paddings */
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .product-card .product-info { padding: 8px; }
    .product-card .product-name { font-size: 13px; }
    .product-card .product-price { font-size: 16px; }
    .product-card .product-img { height: 220px; }
    .btn-add-cart { width: calc(100% - 20px); margin: 8px 10px; }

    .stat-cards { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-card .stat-value { font-size: 22px; }
    .stat-card .stat-icon { display: none; }

    .order-card { flex-direction: column; align-items: flex-start; }

    /* Timeline stacks vertical */
    .timeline { flex-direction: column; gap: 16px; }
    .timeline::before {
        top: 0; bottom: 0;
        left: 18px; right: auto;
        width: 3px; height: auto;
    }
    .timeline-step { text-align: left; display: flex; align-items: center; gap: 16px; }
    .timeline-step .step-dot { margin: 0; }

    /* Cart responsive */
    .cart-table thead { display: none; }
    .cart-table tr {
        display: block;
        padding: 16px 0;
        border-bottom: 1px solid var(--border);
    }
    .cart-table td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        border: none;
    }
    .cart-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        color: var(--text-muted);
        text-transform: uppercase;
    }
    .cart-summary { max-width: 100%; margin-left: 0; }

    /* Data table horizontal scroll */
    .data-table-wrap { overflow-x: auto; }

    .hero h1 { font-size: 26px; }
    .hero p { font-size: 14px; }

    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .page-header h1 { font-size: 20px; }

    .search-bar { max-width: 100%; }

    .modal-box { width: 100%; margin: 16px; border-radius: var(--radius-md); }
    .modal-body { padding: 16px; }

    .category-bar a { padding: 12px 16px; font-size: 12px; }

    .admin-footer { flex-direction: column; gap: 4px; text-align: center; }
}

/* ---------- Small Mobile  ---------- */
@media (max-width: 480px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-cards { grid-template-columns: 1fr; }
    .btn-group { flex-direction: column; }

    .hero { padding: 36px 0; }
    .hero h1 { font-size: 22px; }

    .product-detail .product-gallery img { height: 250px; }
    .product-detail .product-meta .price-tag { font-size: 26px; }
    .pd-gallery__img { height: 260px; }
    .pd-price { font-size: 28px; }
    .pd-info__title { font-size: 22px; }
    .pd-reviews__list { grid-template-columns: 1fr; }
    .pd-reviews__avg-num { font-size: 36px; }
    .pd-actions { flex-direction: column; }
    .pd-btn-cart { width: 100%; }

    .quick-actions { flex-wrap: wrap; }
    .quick-actions .btn { flex: 1; min-width: 120px; }

    .pagination a, .pagination span { width: auto !important; min-width: 32px; height: 32px; font-size: 12px; padding: 0 10px; }
    .pagination .btn { width: auto !important; }
}

/* Strong overrides to ensure consistent product layout on narrow devices (fix narrow columns) */
@media (max-width: 430px) {
    .product-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .product-card { width: 100%; margin: 0; }
    .product-card .product-img { height: 160px !important; }
    .product-card .product-info { padding: 8px 10px !important; }
    .product-card .product-name { font-size: 12.5px !important; }
    .product-card .product-price { font-size: 15px !important; }
    .btn-add-cart { width: calc(100% - 16px) !important; margin: 6px 8px !important; }
}

@media (max-width: 360px) {
    /* Very small phones: single column for readability */
    .product-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
    .product-card .product-img { height: 260px !important; }
    .product-card .product-info { padding: 12px !important; }
    .btn-add-cart { width: 100% !important; margin: 8px 0 !important; }
}

/* Checkout-specific small-screen fixes: ensure summary stacks and is visible */
@media (max-width: 480px) {
    .checkout-grid { grid-template-columns: 1fr !important; gap: 18px !important; }
    .checkout-sidebar { order: 2; width: 100%; }
    .checkout-main { order: 1; width: 100%; }
    .cart-summary, .co-summary { position: static !important; max-width: 100% !important; margin-left: 0 !important; }
    .cart-summary .btn-block, .co-summary-actions .btn { width: 100% !important; }
}

@media (max-width: 430px) {
    .checkout-grid { grid-template-columns: 1fr !important; }
    .checkout-sidebar, .checkout-main { width: 100% !important; }
    .cart-summary { padding: 16px !important; }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .top-bar, .navbar, .admin-footer, .btn, .action-group,
    .category-bar, .search-bar, .pagination { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    body { font-size: 12px; color: #000; }
    .data-table th { background: #000; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .stat-card { border: 1px solid #000; break-inside: avoid; }
    .stat-card::before { display: none; }
}
