/* ===========================================================
   Elys Hair GH — Global Responsive Layer
   Targets: Mobile (<=575px), Tablet (576–991px),
            Desktop (>=992px), Large Desktop (>=1400px)
   Loaded LAST — overrides existing rules where needed.
   =========================================================== */

/* -- Base fluid safety --------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
img, video, canvas, svg, iframe { max-width: 100%; height: auto; }
video { display: block; }
.table-responsive { -webkit-overflow-scrolling: touch; }

/* Prevent long words/URLs breaking layout */
.panel, .card, .zone-card, .checkout-summary, .footer, .hero-inner,
.summary-item, .breadcrumb, .btn, .badge { word-wrap: break-word; overflow-wrap: anywhere; }

/* Cart rows: reset the inherited overflow-wrap:anywhere above so flex layout
   doesn't shrink the product name's intrinsic width down to a single
   character on narrow screens (causes vertical letter-stacking on mobile). */
.cart-row-info { min-width: 0; overflow-wrap: normal; word-break: normal; }
.cart-row-thumb, .cart-row-actions { flex-shrink: 0; }

/* Sticky panels only stick when there's room */
.checkout-summary, .shop-sidebar, .product-buy-panel { position: static !important; }
@media (min-width: 992px) {
    .checkout-summary, .shop-sidebar, .product-buy-panel { position: sticky !important; top: 88px !important; }
}

/* ============================================================
   MOBILE  (<= 575.98px)
   ============================================================ */
@media (max-width: 575.98px) {
    :root { font-size: 15px; }

    .container, .container-fluid { padding-left: 14px; padding-right: 14px; }

    /* Typography scale down */
    h1, .h1 { font-size: 1.75rem; line-height: 1.2; }
    h2, .h2 { font-size: 1.4rem; }
    h3, .h3 { font-size: 1.2rem; }
    h4, .h4 { font-size: 1.1rem; }
    .display-1, .display-2, .display-3, .display-4, .display-5, .display-6 { font-size: 2rem; }

    /* Section padding */
    .section, .section-pad { padding-top: 2rem !important; padding-bottom: 2rem !important; }

    /* Panels & cards */
    .panel { padding: 1rem !important; border-radius: 14px; }

    /* Buttons full-width on very small viewports where sensible */
    .btn-brand.w-100, .btn.w-100 { padding: .7rem 1rem; font-size: 1rem; }

    /* Navbar / topnav */
    .navbar { padding: .5rem .75rem; }
    .brand-logo-pill img { max-height: 36px; }
    .nav-cart-badge { transform: scale(.9); }

    /* Hero */
    .hero-inner, .hero { text-align: center; padding: 1.25rem 0 .5rem; }
    .hero-logo-stage { width: 140px !important; height: 140px !important; margin: 0 auto; }
    .hero-buttons, .hero-cta { justify-content: center !important; }
    .hero-buttons .btn { width: 100%; }

    /* Home feature cards → stack */
    .feature-cards .col-md-4, .feature-cards .col-lg-4 { flex: 0 0 100%; max-width: 100%; }

    /* Product details */
    .product-media, .product-gallery { border-radius: 14px; }
    .product-title { font-size: 1.4rem; }
    .price-tag { font-size: 1.25rem; }
    .color-chip, .zone-card { padding: .65rem !important; }
    .qty-controls .btn { padding: .35rem .6rem; }

    /* Checkout */
    .checkout-page .zone-card { padding: .75rem !important; }
    .checkout-page .zone-card .zone-title { font-size: .95rem; }
    .checkout-page .zone-card .zone-desc { font-size: .8rem; }
    .checkout-page .trust-strip { flex-wrap: wrap; gap: .5rem; font-size: .78rem; }
    .checkout-page .trust-strip > div { flex: 1 1 45%; justify-content: center; }
    .checkout-summary .summary-item img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; }

    /* Tables → horizontal scroll instead of collapse */
    .panel > .table, .panel table.table { min-width: 560px; }
    .panel.table-responsive { overflow-x: auto; }

    /* Cart rows → stack into two lines instead of squeezing into one */
    .cart-row-info { flex: 1 1 100%; order: 2; }
    .cart-row-thumb { order: 1; }
    .cart-row-actions { flex: 1 1 100%; order: 3; justify-content: space-between; margin-top: .35rem; }
    .cart-row-price { min-width: auto !important; }

    .table .item-name, .table .wrap { white-space: normal; }

    /* Chips / badges wrap */
    .chip, .badge { font-size: .72rem; }

    /* Footer */
    footer .footer-cols { text-align: center; }
    footer .footer-cols [class*="col-"] { margin-bottom: 1rem; }
    footer .footer-socials { justify-content: center; }

    /* Floating action buttons don't collide with content */
    .whatsapp-fab, .ai-fab, .chat-fab { bottom: 14px !important; right: 14px !important; }
    .whatsapp-fab { bottom: 78px !important; }

    /* Modals: full-height friendly */
    .modal-dialog { margin: .5rem; }
    .modal-content { border-radius: 14px; }

    /* Admin */
    .admin-sidebar { position: static !important; width: 100% !important; }
    .admin-topnav .nav-link { padding: .5rem .75rem; }
    .stats-card { padding: 1rem !important; }
    .stats-card .stat-value { font-size: 1.4rem; }
    .chart-wrap, .chart-container { height: 240px !important; }
}

/* ============================================================
   TABLET  (576px – 991.98px)
   ============================================================ */
@media (min-width: 576px) and (max-width: 991.98px) {
    :root { font-size: 15.5px; }

    .container { padding-left: 18px; padding-right: 18px; }
    .section, .section-pad { padding-top: 2.5rem !important; padding-bottom: 2.5rem !important; }
    .panel { padding: 1.25rem; }

    /* Hero side-by-side but tighter */
    .hero-logo-stage { width: 180px !important; height: 180px !important; }
    h1, .h1 { font-size: 2rem; }
    .display-5 { font-size: 2.4rem; }

    /* Home feature cards → 2 up */
    .feature-cards .col-md-4, .feature-cards .col-lg-4 { flex: 0 0 50%; max-width: 50%; }

    /* Product grid: 2 columns on catalog */
    .product-grid .col, .product-grid > [class*="col-"] { flex: 0 0 50%; max-width: 50%; }

    /* Shop sidebar shows above grid, full width */
    .shop-layout .shop-sidebar { margin-bottom: 1rem; }

    /* Checkout: keep 2-column but reduce sticky offset */
    .checkout-page .checkout-summary { top: 76px !important; }
    .checkout-page .zone-card { padding: .85rem; }

    /* Tables: horizontal scroll for anything wider than viewport */
    .panel > .table, .panel table.table { min-width: 640px; }
    .panel.table-responsive { overflow-x: auto; }

    /* Admin dashboard: stats 2-per-row */
    .stats-grid > [class*="col-"] { flex: 0 0 50%; max-width: 50%; }
    .chart-wrap, .chart-container { height: 280px !important; }

    /* Footer: 2 columns */
    footer .footer-cols [class*="col-"] { flex: 0 0 50%; max-width: 50%; margin-bottom: 1.25rem; }
}

/* ============================================================
   DESKTOP  (>= 992px)
   ============================================================ */
@media (min-width: 992px) {
    .container { max-width: 1140px; }
    .section, .section-pad { padding-top: 3.5rem; padding-bottom: 3.5rem; }
    .hero-logo-stage { width: 240px; height: 240px; }
    .chart-wrap, .chart-container { height: 320px; }
    .product-grid > [class*="col-"] { flex: 0 0 33.3333%; max-width: 33.3333%; }
    .feature-cards .col-md-4, .feature-cards .col-lg-4 { flex: 0 0 33.3333%; max-width: 33.3333%; }
    footer .footer-cols [class*="col-"] { margin-bottom: 0; }
}

/* ============================================================
   LARGE DESKTOP  (>= 1400px)
   ============================================================ */
@media (min-width: 1400px) {
    .container { max-width: 1320px; }
    .product-grid > [class*="col-"] { flex: 0 0 25%; max-width: 25%; }
    .stats-grid > [class*="col-"] { flex: 0 0 25%; max-width: 25%; }
}

/* ============================================================
   TOUCH / POINTER refinements
   ============================================================ */
@media (hover: none) {
    /* Bigger tap targets on touch devices */
    .btn, .nav-link, .zone-card, .color-chip { min-height: 44px; }
    .color-chip { min-width: 44px; }
    /* Disable heavy hover transforms on touch */
    .panel:hover, .card:hover, .product-card:hover, .zone-card:hover { transform: none !important; }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
    .navbar, footer, .whatsapp-fab, .ai-fab, .chat-fab, .marquee, .announcement-modal { display: none !important; }
    body { background: #fff; }
    .panel { box-shadow: none !important; border: 1px solid #eee !important; }
}

/* ============================================================
   Mobile nav toggler (Bootstrap built-in icon, recolored)
   ============================================================ */
.elys-nav-toggler {
    border: 1px solid rgba(122, 26, 143, .25) !important;
    padding: .35rem .6rem !important;
    background: rgba(122, 26, 143, .08) !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}
.elys-nav-toggler:focus {
    box-shadow: 0 0 0 .2rem rgba(160, 60, 170, .25) !important;
    outline: none;
}
.elys-nav-toggler:hover { background: rgba(122, 26, 143, .16) !important; }
.elys-nav-toggler .navbar-toggler-icon {
    width: 1.5em;
    height: 1.5em;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath stroke='%237a1a8f' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2.5' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
}

@media (min-width: 992px) {
    .elys-nav-toggler { display: none !important; }
}

/* Ensure mobile menu items are large tap targets */
@media (max-width: 991.98px) {
    .elys-navbar .navbar-nav .nav-link {
        padding: .75rem 1rem;
        font-size: 1.05rem;
    }
    .elys-navbar .navbar-collapse {
        padding-top: .5rem;
    }
}
