/* ============================================
   F1 Live — Premium Racing Theme
   ============================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

:root {
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-panel: #16161f;
    --bg-chat: #1a1a25;
    --bg-input: #1e1e2a;
    --accent: #e10600;
    --accent-glow: rgba(225, 6, 0, 0.4);
    --accent-light: #ff3b36;
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --border: #2a2a3a;
    --success: #00d26a;
    --error: #ff4757;
    --chat-system: #6c6c88;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html,
body {
    height: 100vh;
    height: 100dvh;
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

/* --- Gate --- */
.gate {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

.gate-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, var(--accent-glow), transparent 70%),
        radial-gradient(ellipse 60% 40% at 80% 110%, rgba(100, 0, 200, 0.15), transparent),
        var(--bg-dark);
    z-index: 0;
}

.gate-glow {
    position: absolute;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    opacity: 0.3;
    animation: pulse-glow 4s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        transform: translateX(-50%) scale(1);
        opacity: 0.3;
    }

    50% {
        transform: translateX(-50%) scale(1.15);
        opacity: 0.5;
    }
}

.gate-card {
    position: relative;
    z-index: 1;
    background: rgba(18, 18, 26, 0.85);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 50px 45px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), 0 0 80px var(--accent-glow);
    animation: card-enter 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform: translateY(30px);
    opacity: 0;
}

@keyframes card-enter {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.gate-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 20px var(--accent-glow));
}

.gate-logo h1 {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.accent {
    color: var(--accent);
    text-shadow: 0 0 30px var(--accent-glow);
}

.gate-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 6px;
    font-weight: 300;
}

.gate-form {
    margin-top: 35px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group input {
    width: 100%;
    padding: 16px 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    text-align: center;
    letter-spacing: 3px;
    transition: var(--transition);
    outline: none;
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow), 0 0 20px var(--accent-glow);
}

.input-group input::placeholder {
    font-family: var(--font);
    letter-spacing: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.gate-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent), #c00500);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.gate-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
    opacity: 0;
    transition: var(--transition);
}

.gate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--accent-glow);
}

.gate-btn:hover::after {
    opacity: 1;
}

.gate-btn:active {
    transform: translateY(0);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.gate-error {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 12px;
    animation: shake 0.3s ease;
}

@keyframes shake {
    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.gate-help {
    margin-top: 25px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.gate-help code {
    background: var(--bg-input);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--accent-light);
    font-size: 0.85rem;
}

/* --- Live View --- */
.live-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    animation: fade-in 0.6s ease;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Header */
.live-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(225, 6, 0, 0.15);
    color: var(--accent);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(225, 6, 0, 0.3);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(225, 6, 0, 0);
    }
}

.live-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-count {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.user-count .dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: dot-blink 2s ease infinite;
}

@keyframes dot-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.current-user {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 300;
}

.logout-btn {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.2);
    color: var(--error);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.logout-btn:hover {
    background: rgba(255, 71, 87, 0.2);
}

/* Main content */
.live-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Player */
.player-container {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
}

.player-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

.video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    z-index: 5;
}

.player-overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
}

.overlay-content p {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.overlay-sub {
    font-size: 0.85rem !important;
    color: var(--text-muted) !important;
    margin-top: 8px;
}

.pulse-ring {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    animation: ring-pulse 1.5s ease-out infinite;
}

@keyframes ring-pulse {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* Chat Panel */
.chat-panel {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.chat-users {
    background: var(--bg-input);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

/* Chat Messages */
.chat-msg {
    animation: msg-in 0.2s ease;
    line-height: 1.5;
    word-break: break-word;
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg .chat-username {
    font-weight: 700;
    font-size: 0.85rem;
    margin-right: 6px;
}

.chat-msg .chat-text {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.chat-msg.system {
    color: var(--chat-system);
    font-size: 0.8rem;
    font-style: italic;
    text-align: center;
    padding: 4px 0;
}

/* Chat Input */
.chat-form {
    display: flex;
    gap: 0;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: var(--bg-chat);
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
}

.chat-input:focus {
    border-color: var(--accent);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send {
    padding: 10px 16px;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.chat-send:hover {
    background: var(--accent-light);
}

/* --- Responsive Settings for Tablet & Mobile --- */
@media (max-width: 950px) {
    .live-main {
        flex-direction: column;
    }

    .player-container {
        flex: none;
        width: 100%;
        /* Force 16:9 ratio for the video on mobile */
        aspect-ratio: 16 / 9;
        height: auto;
    }

    .chat-panel {
        width: 100%;
        flex: 1;
        /* Chat prend tout le reste de l'écran en bas */
        height: auto;
        border-left: none;
        border-top: 1px solid var(--border);
    }
}

@media (max-width: 500px) {
    .gate-card {
        margin: 20px;
        padding: 30px 20px;
        width: calc(100% - 40px);
    }

    .gate-icon {
        font-size: 40px;
    }

    .gate-logo h1 {
        font-size: 1.6rem;
    }

    /* Options d'en-tête mobile */
    .live-header {
        padding: 10px 16px;
    }

    .live-badge {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .live-header h2 {
        font-size: 1rem;
    }

    .header-right .current-user {
        display: none;
        /* Gagner de la place en haut */
    }

    .chat-input {
        font-size: 16px;
        /* Évite au clavier iOS de zoomer automatiquement */
    }
}