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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--gradient-hero);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 80px 80px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.48), transparent 90%);
    opacity: 0.4;
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

.container {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
}

header {
    padding: 28px 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    position: relative;
    z-index: 40;
}

.header-right,
nav {
    display: flex;
    align-items: center;
}

.header-right {
    gap: 22px;
}

.header-actions,
.header-language-slot,
.page-language-slot {
    display: flex;
    align-items: center;
}

.header-actions {
    gap: 12px;
}

nav {
    gap: 22px;
    flex-wrap: wrap;
}

.nav-row {
    display: contents;
}

nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: color 0.2s ease, opacity 0.2s ease;
}

nav a:hover,
nav a.active {
    color: var(--text);
}

.language-switcher {
    position: relative;
}

.language-trigger,
.language-option {
    border: 1px solid rgba(110, 154, 186, 0.18);
    background: rgba(7, 17, 26, 0.72);
}

.language-trigger {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

.language-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    display: grid;
    gap: 10px;
    min-width: 168px;
    padding: 12px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(7, 17, 26, 0.96);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 10010;
}

.language-dropdown[hidden] {
    display: none !important;
}

.language-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 14px;
    cursor: pointer;
    color: var(--text);
}

.language-option:hover,
.language-trigger:hover {
    border-color: rgba(34, 199, 168, 0.34);
    transform: translateY(-1px);
}

.language-flag {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}

.language-option-label {
    font-size: 0.92rem;
    font-weight: 700;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: fit-content;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    text-decoration: none;
    color: var(--text);
}

.logo::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gradient-accent);
    box-shadow: 0 0 0 6px rgba(34, 199, 168, 0.12);
}

.cta-button,
.search-button,
.tab-btn,
.tier-select,
.admin-search-bar,
.date-select {
    transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, background-color 0.22s ease;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(34, 199, 168, 0.35);
    background: var(--gradient-accent);
    color: #041018;
    padding: 14px 26px;
    border-radius: var(--radius-pill);
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 18px 35px rgba(25, 184, 154, 0.2);
}

.cta-button:hover,
.search-button:hover,
.tab-btn:hover {
    transform: translateY(-1px);
}

:focus-visible {
    outline: 3px solid rgba(77, 163, 255, 0.5);
    outline-offset: 2px;
}

footer {
    padding: 72px 0 40px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 18px;
}

.footer-links a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
}

.footer-copyright {
    font-size: 0.82rem;
    color: var(--text-faint);
}

.state-panel {
    grid-column: 1 / -1;
    padding: 20px 22px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(7, 17, 26, 0.72);
    color: var(--text-dim);
    text-align: center;
}

.state-panel.is-error {
    color: #ffd6d6;
    border-color: rgba(255, 107, 107, 0.28);
    background: rgba(68, 17, 23, 0.35);
}

.state-panel.is-success {
    color: #d4f7ec;
    border-color: rgba(33, 199, 122, 0.22);
    background: rgba(12, 56, 42, 0.35);
}

@media (max-width: 900px) {
    header {
        flex-direction: column;
        align-items: stretch;
    }

    .logo {
        margin-bottom: 12px;
        width: fit-content;
    }

    .header-right {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end; /* Align nav and profile to the right */
        gap: 16px;
    }

    .header-actions {
        margin-left: auto;
    }
}

@media (max-width: 640px) {
    .container {
        width: min(100% - 24px, 1240px);
    }

    header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "logo actions"
            "nav nav";
        align-items: start;
        padding-top: 18px;
        padding-bottom: 0;
        row-gap: 12px;
        column-gap: 12px;
    }

    .logo {
        grid-area: logo;
        margin-bottom: 0;
    }

    .header-right {
        display: contents;
    }

    nav {
        grid-area: nav;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        min-width: 0;
        padding: 10px 14px 12px;
        border-radius: 20px;
        border: 1px solid rgba(110, 154, 186, 0.16);
        background: rgba(7, 17, 26, 0.36);
    }

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

    .nav-row-primary {
        width: 100%;
        justify-content: flex-start;
        gap: 12px;
    }

    nav a {
        font-size: 0.88rem;
        padding: 9px 12px;
        border-radius: 999px;
        border: 1px solid rgba(110, 154, 186, 0.14);
        background: rgba(19, 38, 54, 0.52);
        color: var(--text-dim);
    }

    nav a:hover,
    nav a.active {
        background: rgba(25, 184, 154, 0.12);
        border-color: rgba(25, 184, 154, 0.2);
        color: var(--text);
    }

    .header-actions {
        grid-area: actions;
        justify-self: end;
        align-self: start;
        gap: 6px;
    }

    .user-profile-section,
    .header-language-slot {
        margin: 0;
    }

    .language-trigger {
        width: 40px;
        height: 40px;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.16);
    }

    .language-flag {
        width: 21px;
        height: 21px;
    }
}
