/* ================================================================
   GovindRajbhar — RESPONSIVE FIX v4.0
   Focused: layout corrections only — design tokens in stabilization.css
   ================================================================ */

/* ── Global box model (belt+suspenders) ── */
*, *::before, *::after { box-sizing: border-box; }

html { overflow-x: hidden; scroll-behavior: smooth; }

body { overflow-x: hidden; word-wrap: break-word; overflow-wrap: break-word; }

img, video, iframe, embed, object { max-width: 100%; height: auto; }

/* ── Container ── */
.container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

/* ── Buttons: no tap delay ── */
button, .btn, a.btn {
    max-width: 100%;
    word-break: break-word;
    touch-action: manipulation;
}

a, button, [role="button"], input[type="submit"], input[type="button"] {
    touch-action: manipulation;
}

p, h1, h2, h3, h4, h5, h6, span, li, td, th {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ── Header sticky ── */
.hdr-navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

/* ── Footer ── */
.footer { width: 100%; padding-left: 0; padding-right: 0; }
.footer .container,
.footer > .container { width: 100%; max-width: 1200px; }

/* ── Grid ── */
.grid-2, .grid-3 { display: grid; gap: 1.5rem; }

/* Tables always scrollable */
.table-responsive, .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

/* ── Admin panel ── */
.admin-topbar { padding: 0 1.25rem; gap: 0.75rem; }
.admin-content { padding: 1.5rem; }

.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1050;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.admin-sidebar-overlay.active { display: block; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
}
.card-header { flex-wrap: wrap; gap: 0.75rem; }
.admin-card .admin-table-wrap,
.admin-card > .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── User sidebar overlay ── */
.user-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1050;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.user-sidebar-overlay.active { display: block; }

/* ── 1024px breakpoint ── */
@media (max-width: 1024px) {
    .admin-sidebar { left: calc(var(--sidebar-width, 260px) * -1); }
    .admin-sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,0.2); }
    .admin-main { margin-left: 0 !important; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-layout { grid-template-columns: 1fr; }
    .container { padding-left: 15px; padding-right: 15px; }
    .admin-content { padding: 1.25rem; }
}

/* ── 768px breakpoint ── */
@media (max-width: 768px) {
    .admin-topbar {
        padding: 0 1rem;
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    .page-title { font-size: 1rem; }
    .admin-info { display: none; }
    .admin-content { padding: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .stats-card { padding: 1rem; gap: 0.75rem; }
    .stats-icon { width: 42px; height: 42px; font-size: 1.25rem; }
    .stats-info h3 { font-size: 1.4rem; }
    .card-header { padding: 1rem; }
    .card-header h3 { font-size: 1rem; }
    .admin-table th, .admin-table td { padding: 0.75rem 1rem; }

    /* Header topbar */
    .hdr-topbar-left { font-size: 0.72rem; }

    /* Hero */
    .hero-new { padding: 3rem 0 2.5rem; min-height: auto; }
    .hero-title { font-size: clamp(1.5rem, 5.5vw, 2.25rem) !important; }

    /* User panel */
    .user-layout { grid-template-columns: 1fr !important; }
    .mobile-sidebar-btn { display: flex !important; }
    .btn-block-mobile { width: 100%; justify-content: center; }

    /* Footer */
    .footer-grid { grid-template-columns: 1fr !important; gap: 2rem !important; }

    /* Bottom bar clearance */
    body.has-sticky-bottom-bar { padding-bottom: 75px; }
}

/* ── 480px breakpoint ── */
@media (max-width: 480px) {
    .container { padding-left: 12px; padding-right: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
    .admin-topbar .topbar-right { gap: 0.5rem; }
    .admin-avatar { width: 32px; height: 32px; font-size: 1rem; }
    .hero-new { padding: 2.5rem 0 2rem; }
    .hero-title { font-size: clamp(1.35rem, 6vw, 1.8rem) !important; }
    h2, .section-heading h2 { font-size: clamp(1.25rem, 5vw, 1.75rem) !important; }
    .btn { font-size: 0.88rem; padding: 0.65rem 1.1rem; }
    .product-title { font-size: 1.5rem; }

    /* Floating buttons — stay left, never overlap AI on right */
    .floating-actions { bottom: 20px; left: 14px; right: auto; }
}

/* ── Admin sidebar animation ── */
.admin-sidebar { transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.admin-sidebar * { max-width: 100%; }

/* ── User sidebar desktop sticky ── */
.user-sidebar { position: sticky; top: 80px; }

@media (max-width: 992px) {
    .user-sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        height: 100vh;
        width: 280px;
        border-radius: 0;
        z-index: 1100;
        overflow-y: auto;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }
    .user-sidebar.open { left: 0; }

    .mobile-sidebar-btn {
        display: flex !important;
        align-items: center;
        gap: 0.5rem;
        background: #1f2937;
        color: white;
        border: none;
        padding: 0.65rem 1.25rem;
        border-radius: 0.5rem;
        cursor: pointer;
        font-size: 0.9rem;
        font-weight: 700;
        font-family: inherit;
        margin-bottom: 1rem;
        transition: background 0.2s;
    }
    .mobile-sidebar-btn:hover { background: #374151; }
}

/* ── Topbar 400px ── */
@media (max-width: 400px) {
    .hdr-topbar-left a:last-child { display: none; }
    .hdr-topbar-offer { display: none !important; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }

/* ── Adsense anchor ad ── */
.adsense-footer-anchor {
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    text-align: center;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}
body.has-anchor-ad .floating-actions { bottom: 80px !important; }
body.has-anchor-ad .gw-wrap { bottom: 90px !important; }

/* ── Print safe ── */
@media print {
    .hdr-navbar, .hdr-topbar, .footer,
    .floating-actions, .gw-wrap,
    #pwa-popup, #footer-install-pill,
    .admin-sidebar, .admin-topbar,
    .mobile-sidebar-btn { display: none !important; }
    body { overflow: visible !important; }
    .admin-main, .admin-content { margin-left: 0 !important; }
}
