/* ==========================================================================
   Layout chung cho toàn bộ trang public (giới thiệu, sản phẩm, liên hệ,
   tra cứu điểm, sổ xố, đổi thưởng, chính sách...).
   Chỉ chứa: biến thiết kế, reset, body, navbar, footer.
   CSS riêng của từng trang đặt trong @push('styles') của trang đó.
   Nguồn hiển thị: resources/views/layouts/public.blade.php
   ========================================================================== */

:root {
    --pnp-red: #c9182b;
    --pnp-red-hover: #b01424;
    --pnp-red-light: rgba(201, 24, 43, 0.08);
    --pnp-red-border: rgba(201, 24, 43, 0.18);
    --pnp-gold: #f59e0b;
    --pnp-gold-dark: #d97706;
    --pnp-gold-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --pnp-dark: #111111;
    --pnp-gray-text: rgba(17, 17, 17, 0.72);
    --pnp-gray-muted: rgba(17, 17, 17, 0.5);
    --pnp-bg: #f8fafc;
    --pnp-card-bg: #ffffff;
    --pnp-border: #e2e8f0;
    --font-main: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-main);
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 35%, #edf2f7 100%);
    color: var(--pnp-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1, "liga" 1;
}

/* ---------- Top utility bar ---------- */
.nav-topbar {
    background: linear-gradient(90deg, #1a1a1a 0%, #111111 100%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.78rem;
    position: relative;
    z-index: 51;
}

.nav-topbar::after {
    content: "";
    display: block;
    height: 3px;
    background: var(--pnp-gold-gradient);
}

.nav-topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.45rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.nav-topbar-left, .nav-topbar-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.nav-topbar a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; transition: color 0.2s; }
.nav-topbar-left a:hover { color: var(--pnp-gold); }
.nav-topbar-left i { color: var(--pnp-gold); font-size: 0.78rem; }

.nav-topbar-badge {
    display: inline-flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.75);
}
.nav-topbar-badge i { color: #22c55e; }

.nav-topbar-social { display: flex; gap: 8px; }
.nav-topbar-social a {
    width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, 0.08);
    justify-content: center;
}
.nav-topbar-social a:hover { background: var(--pnp-red); color: #fff; }

@media (max-width: 1024px) { .nav-topbar { display: none; } }

/* ---------- Navbar ---------- */
.navbar {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    box-shadow: 0 4px 24px rgba(17, 17, 17, 0.06);
    border-bottom: 1px solid rgba(201, 24, 43, 0.08);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0.7rem 1.5rem;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.35rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.brand-logo:hover { transform: scale(1.02); }

.brand-logo img {
    height: 46px;
    width: auto;
    object-fit: contain;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.cart-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(201, 24, 43, 0.06);
    color: var(--pnp-red);
    font-size: 1.05rem;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.cart-link:hover { background: rgba(201, 24, 43, 0.14); }

.cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--pnp-red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #fff;
}

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: rgba(201, 24, 43, 0.08);
    color: var(--pnp-red);
    font-size: 1.15rem;
    cursor: pointer;
    flex-shrink: 0;
}

.nav-toggle:hover { background: rgba(201, 24, 43, 0.14); }

.nav-menu {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 999px;
    border: none;
    background: none;
    text-decoration: none;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--pnp-dark);
}

.nav-link:hover {
    background: rgba(201, 24, 43, 0.06);
    color: var(--pnp-red);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--pnp-red) 0%, #910f1f 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(201, 24, 43, 0.3);
}

/* ---------- Dropdown: "Khuyến mãi" (Tra cứu điểm / Sổ xố / Đổi thưởng) ---------- */
.nav-dropdown { position: relative; list-style: none; }

.nav-caret { font-size: 0.62rem; margin-left: -2px; transition: transform 0.2s ease; opacity: 0.7; }
.nav-dropdown:hover .nav-caret,
.nav-dropdown.open .nav-caret { transform: rotate(180deg); }

.nav-submenu {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    min-width: 240px;
    margin: 0;
    padding: 0.5rem;
    list-style: none;
    background: #ffffff;
    border: 1px solid var(--pnp-border);
    border-radius: 18px;
    box-shadow: 0 22px 44px rgba(17, 17, 17, 0.14);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 60;
}

.nav-submenu::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-left: 1px solid var(--pnp-border);
    border-top: 1px solid var(--pnp-border);
    border-radius: 3px;
}

.nav-dropdown:hover .nav-submenu,
.nav-dropdown.open .nav-submenu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.nav-sublink {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--pnp-dark);
    white-space: nowrap;
    transition: all 0.15s ease;
}

.nav-sublink i { color: var(--pnp-red); width: 18px; text-align: center; flex-shrink: 0; }

.nav-sublink:hover { background: var(--pnp-red-light); color: var(--pnp-red); }

.nav-sublink.active { background: var(--pnp-red); color: #fff; }
.nav-sublink.active i { color: #fff; }

/* ---------- Footer ---------- */
footer {
    background: #111111;
    color: rgba(255, 255, 255, 0.7);
    padding: 2.5rem 1.5rem 2rem;
    margin-top: auto;
    text-align: center;
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    font-size: 0.85rem;
    line-height: 1.8;
}

.footer-company-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--pnp-gold);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-content a { color: inherit; text-decoration: none; }
.footer-content a:hover { color: var(--pnp-gold); }

.footer-social { display: flex; justify-content: center; gap: 12px; margin: 1rem 0; }

.footer-social a {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: background 0.2s;
}

.footer-social a:hover { background: var(--pnp-red); color: #ffffff; }

.footer-legal { margin-top: 0.75rem; font-size: 0.8rem; }
.footer-legal a { color: var(--pnp-gold); margin: 0 8px; }
.footer-copy { margin-top: 1.25rem; font-size: 0.8rem; opacity: 0.75; }

/* ---------- Responsive: menu thu gọn trên tablet/mobile ---------- */
@media (max-width: 1024px) {
    .navbar { padding: 0.6rem 1rem; }
    .nav-container { padding: 0; gap: 8px; flex-wrap: nowrap; }
    .brand-logo img { height: 38px; }
    .nav-right { gap: 10px; flex-wrap: nowrap; }
    .nav-toggle { display: inline-flex; }
    .nav-menu {
        display: none;
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;
        gap: 6px;
    }
    .nav-menu.open { display: flex; }

    /* Menu chính: thả xuống dạng panel full chiều ngang ngay dưới header (không chen vào hàng logo) */
    .nav-right > .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        padding: 0.75rem 1rem 1rem;
        background: #ffffff;
        border-top: 1px solid rgba(201, 24, 43, 0.08);
        box-shadow: 0 18px 32px rgba(17, 17, 17, 0.12);
        max-height: calc(100vh - 64px);
        max-height: calc(100dvh - 64px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .nav-right > .nav-menu .nav-link {
        width: 100%;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 16px;
        border-radius: 14px;
        font-size: 0.92rem;
    }
    .nav-right > .nav-menu .nav-link > i:first-child { width: 20px; text-align: center; flex-shrink: 0; }
    .nav-right > .nav-menu .nav-caret { margin-left: auto; }

    /* Dropdown "Khuyến mãi" trở thành khối xổ xuống (accordion) ngay trong menu mobile */
    .nav-dropdown { width: 100%; }
    .nav-dropdown-trigger { width: 100%; }
    .nav-submenu {
        position: static;
        display: none;
        min-width: 0;
        margin-top: 6px;
        padding: 6px;
        background: rgba(201, 24, 43, 0.04);
        border: none;
        border-radius: 14px;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }
    .nav-submenu::before { display: none; }
    .nav-dropdown:hover .nav-submenu { transform: none; }
    .nav-dropdown.open .nav-submenu { display: flex; flex-direction: column; gap: 4px; transform: none; }
    .nav-sublink { padding: 0.7rem 0.85rem 0.7rem 2.6rem; white-space: normal; }
}

@media (max-width: 480px) {
    .navbar { padding: 0.5rem 0.85rem; }
    .brand-logo img { height: 34px; }
}

/* ---------- Mobile: chống lỗi chung ---------- */
/* body là flex-column: phần tử con có margin auto sẽ bị co theo nội dung -> ép full chiều rộng
   (max-width riêng của từng khối vẫn giữ nguyên vì :where() không tăng độ ưu tiên) */
body > :where(div, section, main, header, nav) { width: 100%; }

html, body { overflow-x: clip; }

@media (max-width: 768px) {
    /* iOS Safari tự phóng to trang khi focus ô nhập có chữ < 16px -> giữ tối thiểu 16px */
    :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not(.otp-digit-input), select, textarea) {
        font-size: 16px;
    }
}
