/* ============================================
   TESLA-STYLE HEADER & MEGA MENU
   ============================================ */

:root {
    --header-height: 56px;
    --header-bg: #fff;
    --header-text: #393c41;
    --header-text-hover: #000;
    --submenu-bg: #fff;
    --submenu-heading: #000;
    --submenu-link: #171a20;
    --submenu-link-hover: #5c5e62;
    --submenu-border: #f4f4f4;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --transition-speed: 0.3s;
    --transition-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset ---- */
.tesla-header *,
.tesla-header *::before,
.tesla-header *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ---- Header Bar ---- */
.tesla-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10000;
    font-family: var(--font-family);
}

.tesla-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 40px;
    background: var(--header-bg);
    position: relative;
    z-index: 10002;
}

/* ---- Logo ---- */
.tesla-header__logo {
    flex-shrink: 0;
    z-index: 10003;
}

.tesla-header__logo a {
    display: flex;
    align-items: center;
}

.tesla-header__logo img {
    height: 28px;
    width: auto;
}

/* ---- Main Nav ---- */
.tesla-header__nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10002;
}

.tesla-nav__list {
    display: flex;
    align-items: center;
    list-style: none;
    gap: 4px;
}

.tesla-nav__item {
    position: static;
}

.tesla-nav__link {
    display: block;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--header-text);
    text-decoration: none;
    border-radius: 4px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    transition: background var(--transition-speed) var(--transition-ease),
                color var(--transition-speed) var(--transition-ease);
}

.tesla-nav__link:hover,
.tesla-nav__item.active .tesla-nav__link {
    background: rgba(0, 0, 0, 0.05);
    color: var(--header-text-hover);
}

/* ---- Submenu Panel ---- */
.tesla-submenu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    background: var(--submenu-bg);
    border-top: 1px solid var(--submenu-border);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity var(--transition-speed) var(--transition-ease),
                transform var(--transition-speed) var(--transition-ease),
                visibility 0s var(--transition-speed);
    z-index: 10001;
}

.tesla-nav__item.active .tesla-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity var(--transition-speed) var(--transition-ease),
                transform var(--transition-speed) var(--transition-ease),
                visibility 0s 0s;
}

.tesla-submenu__inner {
    display: flex;
    justify-content: center;
    gap: 64px;
    padding: 48px 80px 56px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ---- Submenu Column ---- */
.tesla-submenu__column {
    min-width: 140px;
}

/* Heading (kiểu "Resources", "Location Services") */
.tesla-submenu__heading {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: #000;
    letter-spacing: 0.02em;
    margin-bottom: 20px;
    line-height: 1;
}

/* Sub links dưới heading */
.tesla-submenu__links {
    list-style: none;
}

.tesla-submenu__links li {
    margin-bottom: 4px;
}

.tesla-submenu__links a {
    display: inline-block;
    padding: 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--submenu-link);
    text-decoration: none;
    letter-spacing: 0.01em;
    line-height: 1.5;
    transition: color var(--transition-speed) var(--transition-ease);
}

.tesla-submenu__links a:hover {
    color: var(--submenu-link-hover);
}

/* Single link (menu item không có con) */
.tesla-submenu__single-link {
    display: inline-block;
    padding: 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--submenu-link);
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: color var(--transition-speed) var(--transition-ease);
}

.tesla-submenu__single-link:hover {
    color: var(--submenu-link-hover);
}

/* ---- Right Actions ---- */
.tesla-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    z-index: 10003;
}

.tesla-header__icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--header-text);
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--transition-speed) var(--transition-ease);
}

.tesla-header__icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ---- Search ---- */
.tesla-header__search {
    position: relative;
}

.tesla-search__form {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 40px;
    z-index: 10004;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s 0.2s;
}

.tesla-search__form.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0s 0s;
}

.tesla-search__input {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: var(--font-family);
    color: var(--header-text);
    background: transparent;
}

.tesla-search__input::placeholder {
    color: #aaa;
}

.tesla-search__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--header-text);
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.2s;
}

.tesla-search__close:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ---- Language ---- */
.tesla-header__lang {
    display: flex;
    align-items: center;
}

/* ---- Overlay ---- */
.tesla-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-speed) var(--transition-ease),
                visibility 0s var(--transition-speed);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.tesla-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: opacity var(--transition-speed) var(--transition-ease),
                visibility 0s 0s;
}

/* ---- Body offset cho fixed header ---- */
body {
    padding-top: var(--header-height);
}

/* ---- Hamburger (mobile) ---- */
.tesla-header__hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    gap: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.tesla-header__hamburger:hover {
    background: rgba(0, 0, 0, 0.05);
}

.tesla-header__hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--header-text);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.tesla-header__hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.tesla-header__hamburger.active span:nth-child(2) {
    opacity: 0;
}

.tesla-header__hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}


/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1100px) {
    .tesla-header__inner {
        padding: 0 20px;
    }

    .tesla-submenu__inner {
        gap: 40px;
        padding: 40px 40px 48px;
    }
}

@media (max-width: 960px) {
    /* Show hamburger */
    .tesla-header__hamburger {
        display: flex;
    }

    /* Hide desktop nav */
    .tesla-header__nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 320px;
        height: 100vh;
        background: #fff;
        transform: none;
        left: auto;
        z-index: 10005;
        overflow-y: auto;
        transition: right var(--transition-speed) var(--transition-ease);
        padding: var(--header-height) 0 40px;
    }

    .tesla-header__nav.open {
        right: 0;
    }

    .tesla-nav__list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 16px 0;
    }

    .tesla-nav__link {
        padding: 12px 32px;
        font-size: 15px;
        border-radius: 0;
    }

    /* Submenu mobile */
    .tesla-submenu {
        position: static;
        width: 100%;
        border: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        display: none;
        transition: none;
    }

    .tesla-nav__item.active .tesla-submenu {
        display: block;
    }

    .tesla-submenu__inner {
        flex-direction: column;
        gap: 24px;
        padding: 8px 32px 24px;
    }

    .tesla-submenu__heading {
        margin-bottom: 12px;
    }

    .tesla-submenu__links a,
    .tesla-submenu__single-link {
        font-size: 13px;
        font-weight: 500;
        padding: 4px 0;
    }

    /* Hide lang on mobile (optional) */
    .tesla-header__lang {
        display: none;
    }
}

@media (max-width: 480px) {
    .tesla-header__nav {
        width: 100%;
    }
}
