/* =====================================================
   SieuThiCloud v2 — Layout (header, footer, shell)
   ===================================================== */

/* Form đăng xuất trong header */
.stc-logout-form { display: inline-flex; margin: 0; }
.stc-logout-form .btn { white-space: nowrap; }

/* Main chiếm hết không gian còn lại → footer luôn bám đáy */
#main-content { flex: 1 0 auto; }

/* =================== HEADER =================== */
.stc-header {
    position: sticky;
    top: 0;
    z-index: var(--stc-z-header);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--stc-border);
    transition: box-shadow var(--stc-duration-normal) var(--stc-ease);
}
.stc-header.is-scrolled { box-shadow: var(--stc-shadow-sm); }

.stc-header__inner {
    display: flex;
    align-items: center;
    gap: var(--stc-space-6);
    height: var(--stc-header-height);
}

.stc-header__logo {
    display: inline-flex;
    align-items: center;
    gap: var(--stc-space-2);
    font-size: var(--stc-text-md);
    font-weight: var(--stc-weight-extrabold);
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--stc-text-strong);
    flex-shrink: 0;
}
.stc-header__logo:hover { color: var(--stc-text-strong); }
.stc-header__logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--stc-radius-sm);
    background: var(--stc-gradient-primary);
    color: #fff;
    box-shadow: var(--stc-shadow-primary);
    overflow: hidden;
}
.stc-header__logo-mark img {
    max-width: 28px;
    max-height: 28px;
    object-fit: contain;
}

/* Logo ảnh thật: phủ full ô 38px (đúng cỡ khối SVG fallback), giữ tỉ lệ.
   Bỏ cả nền gradient lẫn bóng xanh — bóng là "khối" bao quanh khi nền trong. */
.stc-header__logo-mark--img {
    background: none;
    box-shadow: none;
}

.stc-header__logo-mark--img img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
}
.stc-header__logo-text em {
    font-style: normal;
    color: var(--stc-primary);
}
.stc-footer__brand .stc-header__logo-text {
    font-size: var(--stc-text-lg);
}

.stc-nav { display: flex; align-items: center; gap: var(--stc-space-1); margin-inline: auto; }
.stc-nav__link {
    display: inline-flex;
    align-items: center;
    padding: var(--stc-space-2) var(--stc-space-4);
    border-radius: var(--stc-radius-xs);
    color: var(--stc-text);
    font-weight: var(--stc-weight-medium);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* bỏ double-tap zoom delay trên mobile */
    transition: background var(--stc-duration-fast) var(--stc-ease),
                color var(--stc-duration-fast) var(--stc-ease);
}
.stc-nav__link:hover { background: var(--stc-primary-soft); color: var(--stc-primary-hover); }
.stc-nav__link.is-active {
    background: var(--stc-primary-soft);
    color: var(--stc-primary-hover);
    font-weight: var(--stc-weight-semibold);
}

.stc-header__actions {
    display: flex;
    align-items: center;
    gap: var(--stc-space-3);
    flex-shrink: 0;
    margin-left: auto;
}

/* Nút mở menu mobile */
.stc-header__toggle { display: none; width: 42px; height: 42px; border-radius: var(--stc-radius-xs); }
.stc-header__toggle:hover { background: var(--stc-primary-soft); }
.stc-header__toggle svg { margin: auto; }

/* =================== LANGUAGE SWITCHER =================== */
.lang-switch { position: relative; flex-shrink: 0; }
.lang-switch__btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid var(--stc-border);
    border-radius: var(--stc-radius-xs);
    background: var(--stc-surface);
    color: var(--stc-text-strong);
    font-size: var(--stc-text-sm);
    font-weight: var(--stc-weight-semibold);
    cursor: pointer;
    transition: border-color var(--stc-duration-fast) var(--stc-ease),
                background var(--stc-duration-fast) var(--stc-ease);
}
.lang-switch__btn:hover { border-color: var(--stc-primary); background: var(--stc-primary-soft); }
.lang-switch__caret { color: var(--stc-text-muted); transition: transform var(--stc-duration-fast) var(--stc-ease); }
.lang-switch.is-open .lang-switch__caret { transform: rotate(180deg); }

/* Menu dropdown */
.lang-switch__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    padding: 6px;
    border: 1px solid var(--stc-border);
    border-radius: var(--stc-radius-md);
    background: var(--stc-surface);
    box-shadow: var(--stc-shadow-lg);
    display: none;
    z-index: var(--stc-z-header);
}
.lang-switch.is-open .lang-switch__menu { display: block; animation: lang-fade 140ms var(--stc-ease); }
@keyframes lang-fade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.lang-switch__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--stc-radius-xs);
    color: var(--stc-text);
    font-size: var(--stc-text-sm);
    transition: background var(--stc-duration-fast) var(--stc-ease);
}
.lang-switch__item:hover { background: var(--stc-primary-soft); }
.lang-switch__item.is-active { background: var(--stc-primary-soft); color: var(--stc-primary-hover); font-weight: var(--stc-weight-semibold); }
.lang-switch__name { color: var(--stc-text-muted); font-size: var(--stc-text-xs); }
.lang-switch__item.is-active .lang-switch__name { color: var(--stc-primary-hover); }

/* Cờ quốc gia */
.lang-flag {
    display: inline-block;
    width: 20px;
    height: 15px;
    border-radius: 2px;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
/* Cờ Việt Nam: SVG nền đỏ + ngôi sao vàng 5 cánh */
.lang-flag--vn {
    background-color: #da251d;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 900 600'%3E%3Crect fill='%23da251d' width='900' height='600'/%3E%3Cpolygon fill='%23ff0' points='450,150 483,252 581,252 502,310 531,412 450,354 369,412 398,310 319,252 417,252'/%3E%3C/svg%3E");
    background-size: cover;
}
/* Cờ Anh: Union Jack SVG chuẩn */
.lang-flag--en {
    background-color: #012169;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 30'%3E%3CclipPath id='t'%3E%3Cpath d='M30,15 h30 v15 z v-15 h-30 z h-30 v-15 z v15 h30 z'/%3E%3C/clipPath%3E%3Cpath d='M0,0 v30 h60 v-30 z' fill='%23012169'/%3E%3Cpath d='M0,0 L60,30 M60,0 L0,30' stroke='%23fff' stroke-width='6'/%3E%3Cpath d='M0,0 L60,30 M60,0 L0,30' clip-path='url(%23t)' stroke='%23C8102E' stroke-width='4'/%3E%3Cpath d='M30,0 v30 M0,15 h60' stroke='%23fff' stroke-width='10'/%3E%3Cpath d='M30,0 v30 M0,15 h60' stroke='%23C8102E' stroke-width='6'/%3E%3C/svg%3E");
    background-size: cover;
}

/* =================== FOOTER =================== */
.stc-footer {
    margin-top: auto;
    background:
        radial-gradient(1000px 400px at 85% -10%, rgba(39, 164, 242, 0.18), transparent 60%),
        var(--stc-neutral-900);
    color: #b9d4e6;
}
.stc-footer__main {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1.2fr;
    gap: var(--stc-space-10);
    padding-block: var(--stc-space-16) var(--stc-space-12);
}
.stc-footer__brand .stc-header__logo { color: #fff; margin-bottom: var(--stc-space-4); }
.stc-footer__brand .stc-header__logo-text em { color: var(--stc-primary); }
.stc-footer__desc { max-width: 320px; font-size: var(--stc-text-md); line-height: var(--stc-leading-relaxed); }

.stc-footer__title {
    color: #fff;
    font-size: var(--stc-text-lg);
    font-weight: var(--stc-weight-semibold);
    margin-bottom: var(--stc-space-4);
}
.stc-footer__links { display: grid; gap: var(--stc-space-3); }
.stc-footer__links a { color: #b9d4e6; font-size: var(--stc-text-md); }
.stc-footer__links a:hover { color: var(--stc-primary); }

.stc-footer__contact { display: grid; gap: var(--stc-space-3); font-size: var(--stc-text-md); }
.stc-footer__contact li { display: flex; gap: var(--stc-space-3); align-items: flex-start; }
.stc-footer__contact svg { flex-shrink: 0; margin-top: 2px; color: var(--stc-primary); }

.stc-footer__bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.10);
    padding-block: var(--stc-space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--stc-space-4);
    font-size: var(--stc-text-sm);
    color: #7fa8c2;
}
.stc-footer__bottom a { color: #7fa8c2; }
.stc-footer__bottom a:hover { color: var(--stc-primary); }
.stc-footer__policy { display: flex; gap: var(--stc-space-4); flex-wrap: wrap; }

/* =================== RESPONSIVE =================== */
@media (max-width: 1024px) {
    .stc-footer__main { grid-template-columns: 1fr 1fr; gap: var(--stc-space-8); }
}

/* Dưới 1000px: ẩn nav desktop, hiển thị actions + nút toggle menu mobile.
   Actions đẩy hẳn sang phải (nav không còn chiếm chỗ với margin-inline auto). */
@media (max-width: 1000px) {
    .stc-nav {
        position: fixed;
        inset: var(--stc-header-height) 0 auto 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--stc-surface);
        border-bottom: 1px solid var(--stc-border);
        box-shadow: var(--stc-shadow-md);
        padding: var(--stc-space-4) var(--stc-space-6) var(--stc-space-6);
        margin: 0;
        display: none;
    }
    .stc-nav.is-open { display: flex; }
    .stc-nav__link { padding: var(--stc-space-3) var(--stc-space-4); border-radius: var(--stc-radius-xs); }
    .stc-header__inner { justify-content: space-between; }
    .stc-header__actions { margin-left: auto; }
    .stc-header__toggle { display: inline-flex; }
}

@media (max-width: 560px) {
    .stc-footer__main { grid-template-columns: 1fr; }
    .stc-footer__bottom { flex-direction: column; text-align: center; }
    .stc-header__actions .btn--ghost { display: none; }
    .lang-switch__btn { padding: 6px 8px; }
    .lang-switch__code { display: none; }
}
