/* ==========================================
   Agrawbic – Full Responsive Media Queries
   Covers: Navbar, Hero, Shop, Cart, Checkout,
   Product, Profile, Admin, Contact, About,
   Track Order, Footer, Forms
   ========================================== */

/* ===== MOBILE HAMBURGER NAV TOGGLE ===== */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    cursor: pointer;
    padding: 6px;
    z-index: 200;
    transition: background 0.2s;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--primary-deep, #1b5e20);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-toggle.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile-only nav items hidden on desktop */
.mobile-only-nav {
    display: none;
}

.navbar-backdrop {
    display: none;
}

.nav-close-row {
    display: none;
}

/* ===== LARGE DESKTOP 1280px+ ===== */
@media (min-width: 1281px) {
    .container {
        max-width: 1280px;
    }
}

/* ===== SMALL LAPTOP / LARGE TABLET 1200px ===== */
@media (max-width: 1200px) {
    .nav-actions {
        gap: 0.8rem;
    }

    .search-box input {
        width: 130px;
    }

    .search-box input:focus {
        width: 165px;
    }
}

/* ===== TABLET/SMALL LAPTOP 1024px ===== */
@media (max-width: 1024px) {

    .product-detail-wrap,
    .cart-page-grid,
    .checkout-grid,
    .story-grid,
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .product-edit-grid {
        grid-template-columns: 1fr;
    }

    .track-grid {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }
}

/* ===== TABLET & MOBILE 991px ===== */
@media (max-width: 991px) {

    /* ----- NAVBAR MOBILE & TABLET ----- */
    .nav-toggle {
        display: flex;
        order: 3;
        background: #f5faf5;
        border: 1px solid rgba(34, 197, 94, 0.2);
    }

    .navbar .container {
        flex-wrap: wrap;
        position: relative;
        gap: 0.7rem 1rem;
    }

    .nav-links.open .nav-close-row {
        display: flex;
    }

    .logo {
        flex: 1;
        font-size: 1.6rem;
    }

    .nav-actions {
        order: 4;
        flex: 1 0 100%;
        width: 100%;
        display: flex;
        align-items: center;
        gap: 0.6rem;
        margin-left: 0;
    }

    .nav-actions .search-form {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
    }

    .nav-actions .search-box {
        display: flex;
        align-items: center;
        width: 100%;
        flex: 1 1 auto;
        min-width: 0;
    }

    /* User menu on desktop → hide on mobile (shown in mobile nav) */
    .nav-actions .user-menu {
        display: none;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        width: min(86vw, 300px);
        min-width: 240px;
        height: 100vh;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        background: #ffffff;
        border-left: 1px solid rgba(34, 197, 94, 0.08);
        padding: 1rem 0.9rem 1.3rem;
        gap: 0;
        box-shadow: -20px 0 56px rgba(22, 62, 39, 0.18);
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
        z-index: 2200;
        overflow-y: auto;
        display: flex;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    }

    .nav-links.open {
        transform: translateX(0);
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links li a {
        display: flex;
        align-items: center;
        padding: 1rem 1rem;
        color: var(--text-primary, #1f2937);
        font-weight: 600;
        background: #f7fdf7;
        margin: 0.4rem 0;
        border-radius: 16px;
        border: 1px solid rgba(72, 187, 120, 0.18);
        transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    }

    .nav-close-row {
        display: none;
        justify-content: flex-end;
        padding: 0.55rem 0;
        margin-bottom: 0.4rem;
    }

    .nav-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border: none;
        border-radius: 50%;
        background: rgba(225, 238, 226, 0.95);
        color: var(--primary-deep, #1b5e20);
        cursor: pointer;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
    }

    .nav-close i {
        font-size: 0.9rem;
    }

    .nav-links li a:hover {
        background: #ecf8ef;
        color: var(--primary-color, #2e7d32);
        transform: translateX(2px);
    }

    .nav-links li a i {
        margin-right: 0.8rem;
        color: var(--primary-color, #2e7d32);
        min-width: 22px;
    }

    .mobile-only-nav {
        display: block;
    }

    .search-box input,
    .search-box input:focus,
    .nav-actions .search-box input,
    .nav-actions .search-box input:focus {
        flex: 1 1 auto;
        width: 100% !important;
        min-width: 90px !important;
    }

    .cart-icon,
    .watchlist-icon {
        flex-shrink: 0;
    }

    .search-results-dropdown {
        position: absolute;
        top: calc(100% + 8px);
        left: 0 !important;
        right: auto !important;
        width: max(100%, min(340px, calc(100vw - 2rem))) !important;
        min-width: min(320px, calc(100vw - 2rem)) !important;
        max-width: calc(100vw - 2rem) !important;
    }

    .navbar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
        z-index: 2100;
    }

    .navbar-backdrop.open {}

    body.nav-open {
        overflow: hidden;
    }

    /* ----- HERO ----- */
    .hero {
        padding: 2rem 0 1.75rem;
        border-radius: 0 0 22px 22px;
    }

    .hero-text h1,
    .hero-text h2 {
        font-size: 2rem;
    }

    .hero-text p {
        font-size: 0.95rem;
        margin: 0.9rem 0 1.2rem;
    }

    .hero-image {
        width: 100%;
        max-width: 100%;
        padding: 0;
        min-height: 280px;
        max-height: 360px;
    }

    .hero-image img {
        max-height: 100%;
        object-fit: cover;
    }

    /* ----- FEATURES / BEST GRID ----- */
    .features-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .best-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    /* ----- PRODUCT GRID ----- */
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }

    /* ----- FOOTER ----- */
    .footer {
        border-radius: 24px 24px 0 0;
    }

    .footer .container {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    /* ----- ADMIN ----- */
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 0.8rem 1rem;
        gap: 0.5rem;
    }

    .admin-brand {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
        font-size: 1.1rem;
    }

    .admin-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .admin-nav a {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    .admin-main {
        padding: 1rem;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    /* ----- HERO MOBILE ----- */
    .hero .container {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-text,
    .hero-image {
        flex: 1 1 100%;
    }

    .hero-image {
        min-height: 260px;
        padding-top: 1rem;
    }

    .hero-image img {
        border-radius: 28px;
    }

    /* ----- PROFILE ----- */
    .account-wrapper {
        grid-template-columns: 1fr !important;
    }

    .account-sidebar {
        position: static !important;
    }

    /* ----- MODAL ----- */
    .modal-content {
        width: 95vw !important;
        max-height: 90vh;
        overflow-y: auto;
        padding: 1.5rem !important;
    }

    /* ----- DATE FILTER ----- */
    .date-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .date-filter-custom {
        margin-left: 0;
    }

    .date-filter-presets {
        justify-content: flex-start;
    }

    /* ----- CARDS ----- */
    .stat-card {
        gap: 0.8rem;
        padding: 1.2rem;
    }

    .stat-info h3 {
        font-size: 1.3rem;
    }

    /* ----- FORMS ----- */
    .form-row {
        flex-direction: column;
        gap: 0.8rem;
        margin-bottom: 0.8rem;
    }

    .form-row .form-group,
    .form-row .form-group.flex-2 {
        flex: none;
        width: 100%;
    }

    .product-edit-grid {
        gap: 1rem;
    }
}

/* ===== MOBILE 480px ===== */
@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }

    .nav-actions .cart-icon {
        font-size: 1.25rem;
    }

    /* ----- HERO ----- */
    .hero {
        padding: 2rem 0;
    }

    .hero-text h2 {
        font-size: 1.7rem;
    }

    .hero-image {
        font-size: 4rem;
        display: none;
    }

    /* ----- GRIDS ----- */
    .product-grid,
    .best-grid,
    .trending-grid,
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.7rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    /* ----- CART PANEL ----- */
    .cart-panel {
        width: 100%;
        max-width: 100vw;
        border-radius: 0;
    }

    /* ----- FILTER BAR ----- */
    .filter-bar {
        gap: 0.4rem 0.6rem;
    }

    .filter-btn {
        padding: 0.3rem 1rem;
        font-size: 0.8rem;
    }

    /* ----- FOOTER ----- */
    .footer .container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* ----- ADMIN ----- */
    .admin-stats-grid {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        display: flex;
        width: 100%;
        overflow-x: auto;
        padding: 0.6rem 0.8rem;
        background: var(--primary-deep, #143014);
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .admin-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        min-width: max-content;
        gap: 0.4rem;
    }

    .admin-nav a {
        white-space: nowrap;
        scroll-snap-align: start;
        font-size: 0.8rem;
        padding: 0.45rem 0.75rem;
    }

    .admin-brand {
        display: none;
    }

    .admin-main {
        padding: 0.85rem;
    }

    /* ----- BUTTONS ----- */
    .btn {
        font-size: 0.88rem;
        padding: 0.55rem 1.2rem;
    }

    .btn-sm {
        font-size: 0.8rem;
        padding: 0.35rem 0.8rem;
    }

    /* ----- TABLE ----- */
    .admin-table {
        font-size: 0.82rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 0.6rem 0.5rem;
    }

    /* ----- PAGE HEADER ROWS ----- */
    .page-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }

    /* ----- PROFILE ----- */
    .account-sidebar {
        padding: 1rem;
    }

    /* ----- PRODUCT CARD ----- */
    .product-img {
        height: 140px;
    }

    .product-name {
        font-size: 0.95rem;
    }

    .product-price {
        font-size: 1rem;
    }

    .best-sellers-carousel .product-card.small-card {
        padding: 0.85rem;
    }

    .best-sellers-carousel .product-card.small-card .product-img {
        min-height: 130px;
    }
}

/* ===== TINY PHONES 360px ===== */
@media (max-width: 360px) {
    .product-grid {
        grid-template-columns: 1fr;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero-text h2 {
        font-size: 1.5rem;
    }

    .nav-links {
        width: 88vw;
        min-width: auto;
    }

    .nav-toggle {
        width: 36px;
        height: 36px;
    }

    .logo {
        font-size: 1.5rem;
    }
}

/* ===== EXTRA SMALL PHONES 320px ===== */
@media (max-width: 320px) {
    .nav-links {
        width: 90vw;
    }

    .nav-actions .search-box input,
    .nav-actions .search-box input:focus {
        width: 100% !important;
        min-width: 60px !important;
    }

    .cart-icon {
        font-size: 1.15rem;
    }
}

/* ===== UTILITY: HIDE ON MOBILE ===== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}


/* ----------- Mobile‑first enhancements (≤480px) ----------- */
@media (max-width: 480px) {

    /* Ensure containers have proper padding */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Cart page: stack grid columns */
    .cart-page-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .cart-table {
        width: 100%;
        overflow-x: auto;
    }

    .cart-table th,
    .cart-table td {
        padding: 0.6rem 0.4rem;
        font-size: 0.85rem;
    }

    .qty-btn {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .cart-item-remove {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    /* Navbar: full‑width mobile menu */
    .nav-links {
        width: 100vw;
        max-width: 100%;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-actions .cart-icon {
        font-size: 1.2rem;
    }

    /* Hero images scale */
    .hero-image img {
        width: 100%;
        height: auto;
        object-fit: cover;
    }

    /* Forms: full‑width inputs */
    .form-control,
    .btn {
        width: 100%;
        box-sizing: border-box;
    }

    .summary-card {
        padding: 1rem;
    }

    .summary-row {
        font-size: 0.9rem;
    }
}

/* ----------- Slightly larger tablets (481px‑768px) ----------- */
@media (min-width: 481px) and (max-width: 768px) {
    .cart-page-grid {
        grid-template-columns: 1fr;
    }

    .nav-links {
        width: 80vw;
    }

    .hero-image img {
        max-height: 320px;
    }
}

/* ---------- Cart Page Grid ---------- */
.cart-page-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .cart-page-grid {
        grid-template-columns: 1fr;
    }
}

/* Ensure container has side padding on small screens */
@media (max-width: 480px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 768px) {
    .admin-sidebar {
        display: flex !important;
        width: 100%;
        overflow-x: auto;
        padding: 0.6rem;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .admin-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        min-width: max-content;
    }

    .admin-nav a {
        white-space: nowrap;
        scroll-snap-align: start;
        font-size: 0.78rem;
        padding: 0.4rem 0.7rem;
        gap: 0.3rem;
    }

    .admin-brand {
        display: none;
    }
}

/* ==========================================
   ULTRA-WIDE & 4K DISPLAY RESPONSIVENESS (≥1441px & ≥1920px)
   ========================================== */
@media (min-width: 1441px) {
    .container {
        max-width: 1400px;
    }
    .admin-main {
        max-width: 1600px;
        margin: 0 auto;
    }
}

@media (min-width: 1920px) {
    .container {
        max-width: 1600px;
    }
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 1.8rem;
    }
    .admin-stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

/* ==========================================
   ULTRA-SMALL MOBILE RESPONSIVENESS (≤320px & ≤360px)
   ========================================== */
@media (max-width: 360px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    .btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.82rem;
    }
    .product-card {
        padding: 0.65rem;
    }
    .product-card-name {
        font-size: 0.85rem;
    }
    .product-price {
        font-size: 0.95rem;
    }
}

@media (max-width: 320px) {
    html, body {
        overflow-x: hidden !important;
    }
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    .nav-actions {
        gap: 0.3rem;
    }
    .logo {
        font-size: 1.35rem;
    }
    .cart-icon, .watchlist-icon {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }
}

/* Product Card Mobile Responsive Fixes - 1 Card Per Row on Mobile */
@media (max-width: 600px) {
    .product-grid,
    .best-grid,
    .trending-grid,
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem;
    }
    .product-card-content, .trending-card-content {
        padding: 1rem 1.1rem;
        gap: 0.5rem;
    }
    .product-card-footer, .trending-card-footer {
        padding-top: 0.6rem;
        gap: 0.5rem;
    }
    .product-price, .trending-price {
        font-size: 1.1rem;
    }
    .btn-product-buy, .btn-trending-buy {
        padding: 0.45rem 0.95rem;
        font-size: 0.82rem;
        gap: 0.35rem;
    }
    .btn-product-buy i, .btn-trending-buy i {
        font-size: 0.8rem;
    }
}