﻿:root {
    --cyber-blue: #00D1FF;
    --cyber-green: #00FFA3;
    --cyber-red: #ff3366;
    --bg-dark: #0A0F1F;
    --bg-panel: #111827;
    --border-panel: #1E293B;
    --font-ui: 'Rajdhani', sans-serif;
    --font-code: 'Fira Code', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: #fff;
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Hiệu ứng background Grid Matrix & Radar */
.grid-bg {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(0, 209, 255, 0.1) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 209, 255, 0.1) 1px, transparent 1px);
    background-size: 40px 40px;
    transform: perspective(500px) rotateX(60deg);
    transform-origin: bottom;
    animation: moveGrid 5s linear infinite;
    z-index: 1;
    opacity: 0.3;
}

@keyframes moveGrid {
    0% {
        transform: perspective(500px) rotateX(60deg) translateY(0);
    }

    100% {
        transform: perspective(500px) rotateX(60deg) translateY(40px);
    }
}

/* Hiệu ứng Scanline màn hình */
.scanline {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(0, 0, 0, 0.3) 51%);
    background-size: 100% 4px;
    z-index: 99;
    pointer-events: none;
    opacity: 0.6;
}

    .scanline::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 10vh;
        background: linear-gradient(to bottom, transparent, rgba(0, 209, 255, 0.2), transparent);
        animation: scan 4s linear infinite;
    }

@keyframes scan {
    0% {
        transform: translateY(-100%);
    }

    100% {
        transform: translateY(1000%);
    }
}

/* Layout chính */
.dashboard {
    position: relative;
    z-index: 10;
    width: 90%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-panel);
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 0 30px rgba(0, 209, 255, 0.1), inset 0 0 20px rgba(0, 209, 255, 0.05);
}

/* Cột trái: Thông tin chính */
.system-status {
    font-family: var(--font-code);
    color: var(--cyber-red);
    font-size: 0.9rem;
    letter-spacing: 2px;
    margin-bottom: 10px;
    animation: blink 1s infinite;
}

.title-glow {
    font-size: 3.5rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 15px;
    text-shadow: 0 0 10px var(--cyber-blue), 0 0 20px var(--cyber-blue);
}

.subtitle {
    font-size: 1.2rem;
    color: #94a3b8;
    margin-bottom: 30px;
}

/* Progress Bar */
.progress-wrapper {
    margin-bottom: 30px;
}

.progress-box {
    height: 12px;
    background: #0f172a;
    border: 1px solid var(--cyber-blue);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin-bottom: 10px;
    box-shadow: 0 0 10px rgba(0, 209, 255, 0.2);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--cyber-blue);
    box-shadow: 0 0 15px var(--cyber-blue);
    transition: width 0.3s ease;
}

.sync-text {
    font-family: var(--font-code);
    font-size: 0.9rem;
    color: var(--cyber-green);
}

/* Warning Box */
.warning-box {
    background: rgba(255, 51, 102, 0.05);
    border-left: 4px solid var(--cyber-red);
    padding: 20px;
    margin-bottom: 30px;
}

.warning-title {
    color: var(--cyber-red);
    font-weight: 600;
    font-size: 1.2rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.warning-list {
    list-style: none;
    color: #cbd5e1;
    font-size: 1.1rem;
}

    .warning-list li {
        margin-bottom: 5px;
    }

        .warning-list li::before {
            content: "•";
            color: var(--cyber-blue);
            margin-right: 10px;
        }

/* Countdown */
.countdown {
    display: flex;
    gap: 20px;
}

.time-box {
    text-align: center;
}

.time-val {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--cyber-green);
    text-shadow: 0 0 10px rgba(0, 255, 163, 0.5);
    font-family: var(--font-code);
}

.time-label {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Cột phải: Terminal Logs */
.terminal {
    background: #000;
    border: 1px solid var(--border-panel);
    border-radius: 6px;
    padding: 20px;
    font-family: var(--font-code);
    font-size: 0.85rem;
    color: #64748b;
    height: 100%;
    overflow-y: hidden;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
}

.terminal-header {
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    margin-bottom: 15px;
    color: var(--cyber-blue);
}

.log-line {
    margin-bottom: 8px;
}

.log-time {
    color: #475569;
    margin-right: 10px;
}

.log-msg {
    color: #a1a1aa;
}

.log-success {
    color: var(--cyber-green);
}

.log-warning {
    color: var(--cyber-red);
}

/* Floating Cards Background */
.floating-card {
    position: absolute;
    background: rgba(0, 209, 255, 0.05);
    border: 1px solid rgba(0, 209, 255, 0.2);
    color: var(--cyber-blue);
    padding: 8px 15px;
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 0.8rem;
    z-index: 5;
    backdrop-filter: blur(4px);
    animation: float 6s ease-in-out infinite;
    white-space: nowrap;
}

.fc-1 {
    top: 15%;
    left: 10%;
    animation-delay: 0s;
}

.fc-2 {
    top: 70%;
    left: 5%;
    animation-delay: 1s;
}

.fc-3 {
    top: 20%;
    right: 10%;
    animation-delay: 2s;
}

.fc-4 {
    top: 80%;
    right: 15%;
    animation-delay: 1.5s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ================= CINEMATIC ACCIDENT ZONE ================= */
.footer-road {
    position: fixed; /* Chuyển từ absolute sang fixed để luôn dính ở đáy */
    bottom: 0;
    left: 0;
    width: 100%;
    height: 160px;
    background: linear-gradient(transparent, rgba(10, 15, 31, 0.98)); /* Làm nền đậm hơn chút để tách biệt với nội dung cuộn phía sau */
    z-index: 999; /* Đảm bảo luôn nằm trên dashboard */
    overflow: visible;
}

/* Kẻ vạch đường Neon */
.road-line {
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    height: 4px;
    background: repeating-linear-gradient(90deg, var(--cyber-blue) 0px, var(--cyber-blue) 20px, transparent 20px, transparent 40px);
    box-shadow: 0 0 10px var(--cyber-blue);
    opacity: 0.6;
}

/* Base Xe */
.cinematic-car {
    position: absolute;
    bottom: 24px;
    font-size: 2rem;
    transition: all 2s cubic-bezier(0.25, 1, 0.5, 1); /* Di chuyển mượt mờ mượt */
}

.car-left {
    left: -10%;
    color: var(--cyber-blue);
    filter: drop-shadow(0 0 8px var(--cyber-blue));
}

.car-right {
    right: -10%;
    color: var(--cyber-red);
    filter: drop-shadow(0 0 8px var(--cyber-red)) scaleX(-1); /* Quay đầu xe lại */
}

/* Hiệu ứng nổ va chạm */
.crash-spark {
    position: absolute;
    left: 50%;
    bottom: 25px;
    transform: translate(-50%, 0) scale(0);
    font-size: 3rem;
    color: #ffaa00;
    filter: drop-shadow(0 0 15px #ff4500);
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 25;
}

/* Anh thợ bảo trì */
.cyber-mechanic {
    position: absolute;
    bottom: -50px; /* Giấu dưới màn hình trước */
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.8rem;
    color: var(--cyber-green);
    filter: drop-shadow(0 0 8px var(--cyber-green));
    transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 22;
    opacity: 0;
}

/* Hologram Bảng Liên Hệ Xuất Hiện Sau Cùng */
.hologram-contacts {
    position: absolute;
    left: 50%;
    bottom: 85px;
    transform: translate(-50%, 20px) scale(0.8);
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid var(--cyber-blue);
    box-shadow: 0 0 20px rgba(0, 209, 255, 0.3), inset 0 0 15px rgba(0, 209, 255, 0.2);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    opacity: 0;
    pointer-events: none; /* Tránh click nhầm khi chưa hiện */
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 30;
    white-space: nowrap;
}

.hologram-title {
    font-size: 0.9rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-right: 1px solid #334155;
    padding-right: 15px;
}

/* Các nút liên hệ */
.holo-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    transition: all 0.3s ease;
}

    .holo-btn.btn-zalo {
        background: #0068ff;
        box-shadow: 0 0 8px rgba(0,104,255,0.4);
    }

    .holo-btn.btn-fb {
        background: #1877f2;
        box-shadow: 0 0 8px rgba(24,119,242,0.4);
    }

    .holo-btn.btn-page {
        background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
        box-shadow: 0 0 8px rgba(220,39,67,0.4);
    }

    .holo-btn:hover {
        transform: translateY(-3px);
        filter: brightness(1.2);
        box-shadow: 0 0 15px var(--cyber-blue);
    }

/* Hệ thống các Class kích hoạt trạng thái bằng JS */
.state-crash .car-left {
    left: calc(50% - 35px);
}

.state-crash .car-right {
    right: calc(50% - 35px);
}

.state-boom .crash-spark {
    transform: translate(-50%, -10px) scale(1.3);
    opacity: 1;
}

.state-boom .cinematic-car {
    animation: carShake 0.3s linear infinite;
}

.state-mechanic .crash-spark {
    transform: translate(-50%, 0) scale(0);
    opacity: 0;
}

.state-mechanic .cyber-mechanic {
    bottom: 26px;
    opacity: 1;
}

.state-ready .hologram-contacts {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

@keyframes carShake {
    0%, 100% {
        transform: translateY(0) (var(--tw-transform,));
    }

    25% {
        transform: translateY(-2px) translateX(-2px);
    }

    75% {
        transform: translateY(2px) translateX(2px);
    }
}

/* ================= ZONE HOÀN TOÀN MỚI CỦA HIỆU ỨNG VA CHẠM DIỆN ẢNH ================= */

/* Thiết lập trạng thái ban đầu của 2 xe khi di chuyển vào giữa */
.state-crash .car-left {
    left: calc(50% - 35px);
}

.state-crash .car-right {
    right: calc(50% - 35px);
}

/* Khi xảy ra va chạm (state-boom): Áp dụng animation nảy bật và chập điện */
.state-boom .car-left {
    animation: carLeftRecoil 0.6s cubic-bezier(.17, .89, .32, 1.1) forwards, neonShortCircuit 0.15s ease infinite;
}

.state-boom .car-right {
    animation: carRightRecoil 0.6s cubic-bezier(.17, .89, .32, 1.1) forwards, neonShortCircuit 0.15s ease infinite;
}

/* Sóng xung kích Cyber xuất hiện từ tâm */
.shockwave {
    position: absolute;
    left: 50%;
    bottom: 35px;
    transform: translate(-50%, 0) scale(0);
    width: 20px;
    height: 20px;
    border: 3px solid var(--cyber-red);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    z-index: 24;
}

.state-boom .shockwave {
    animation: cyberExplosion 0.5s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

/* Khi anh thợ xuất hiện: Làm mờ 2 xe lỗi để dồn sự chú ý vào Hologram */
.state-mechanic .cinematic-car {
    opacity: 0.25;
    filter: grayscale(0.8) drop-shadow(0 0 2px #fff);
    transition: all 1s ease;
}

/* --- HỆ THỐNG KEYFRAMES HOẠT HỌA --- */

/* Xe trái: Lao vào -> Đập mạnh -> Nảy lùi lại 15px -> Đầu xe hếch lên 6 độ */
@keyframes carLeftRecoil {
    0% {
        transform: translateX(0) rotate(0deg);
    }

    12% {
        transform: translateX(-22px) rotate(-8deg) translateY(-4px);
    }
    /* Điểm nảy cực đại */
    30% {
        transform: translateX(-12px) rotate(-4deg);
    }

    50% {
        transform: translateX(-16px) rotate(-6deg);
    }

    70%, 100% {
        transform: translateX(-14px) rotate(-5deg);
    }
    /* Đứng im ở tư thế móp */
}

/* Xe phải: Tương tự xe trái nhưng phải giữ thuộc tính lật ngược scaleX(-1) */
@keyframes carRightRecoil {
    0% {
        transform: scaleX(-1) translateX(0) rotate(0deg);
    }

    12% {
        transform: scaleX(-1) translateX(-22px) rotate(8deg) translateY(-4px);
    }

    30% {
        transform: scaleX(-1) translateX(-12px) rotate(4deg);
    }

    50% {
        transform: scaleX(-1) translateX(-16px) rotate(6deg);
    }

    70%, 100% {
        transform: scaleX(-1) translateX(-14px) rotate(5deg);
    }
}

/* Tạo hiệu ứng đèn Neon chập cheng, mất nguồn điện cấp tốc */
@keyframes neonShortCircuit {
    0%, 100% {
        opacity: 1;
        filter: drop-shadow(0 0 15px currentColor) brightness(1.5);
    }

    45% {
        opacity: 0.2;
        filter: drop-shadow(0 0 2px currentColor) brightness(0.5);
    }

    50% {
        opacity: 0.9;
        filter: drop-shadow(0 0 10px currentColor) brightness(1.2);
    }

    55% {
        opacity: 0.1;
        filter: none;
    }

    80% {
        opacity: 0.8;
        filter: drop-shadow(0 0 8px currentColor);
    }
}

/* Vòng tròn sóng bùng nổ đổi màu từ cam rực sang neon đỏ rồi rộng dần lan tỏa */
@keyframes cyberExplosion {
    0% {
        transform: translate(-50%, 20px) scale(0);
        opacity: 1;
        border-color: #ffaa00;
        box-shadow: 0 0 10px #ffaa00;
    }

    30% {
        border-color: var(--cyber-red);
        box-shadow: 0 0 30px var(--cyber-red);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, 20px) scale(18);
        opacity: 0;
    }
}

/* ================= HIỆU ỨNG KHÓI BỐC LÊN LIÊN TỤC (ĐÃ TỐI ƯU: NHIỀU HƠN, RÕ HƠN) ================= */

/* Khung chứa khói đặt ngay tại tâm va chạm */
.cyber-smoke {
    position: absolute;
    left: 50%;
    bottom: 35px;
    transform: translateX(-50%);
    width: 100px; /* Tăng chiều rộng vùng chứa khói */
    height: 200px; /* Tăng chiều cao vùng bay của khói */
    pointer-events: none;
    z-index: 23; /* Nằm dưới xe và thợ máy nhưng trên mặt đường */
    display: none; /* Mặc định ẩn đi khi xe đang chạy bình thường */
}

/* Kích hoạt khói bốc lên khi bắt đầu va chạm (state-boom) và giữ tiếp ở trạng thái sửa xe (state-mechanic) */
.state-boom .cyber-smoke,
.state-mechanic .cyber-smoke {
    display: block;
}

/* Định dạng chung cho các hạt khói - Tăng độ đậm và kích thước */
.smoke-particle {
    position: absolute;
    bottom: 0;
    left: 50%; /* Căn giữa vùng chứa */
    border-radius: 50%;
    /* TĂNG ĐỘ ĐẬM: Tăng Alpha từ 0.35 lên 0.8 */
    background: rgba(100, 100, 100, 0.8); /* Màu khói xám đậm hơn */
    filter: blur(8px); /* Tăng nhẹ độ blur để trông tự nhiên hơn khi đậm */
    opacity: 0;
    transform-origin: bottom center;
}

    /* Cấu hình thời gian chạy lệch nhau (Delay) và TĂNG KÍCH THƯỚC */
    .smoke-particle.p1 {
        width: 50px; /* Gấp đôi kích thước cũ */
        height: 50px;
        animation: smokeRiseContinuous 3s infinite linear;
        animation-delay: 0s;
    }

    .smoke-particle.p2 {
        width: 70px; /* Gấp đôi kích thước cũ */
        height: 70px;
        background: rgba(80, 80, 80, 0.85); /* Tối và đậm hơn */
        animation: smokeRiseContinuous 3.8s infinite linear;
        animation-delay: 0.5s;
    }

    .smoke-particle.p3 {
        width: 40px; /* Gấp đôi kích thước cũ */
        height: 40px;
        background: rgba(140, 90, 90, 0.6); /* Đỏ sẫm hơn và rõ hơn */
        animation: smokeRiseContinuous 2.5s infinite linear;
        animation-delay: 1s;
    }

    .smoke-particle.p4 {
        width: 60px; /* Gấp đôi kích thước cũ */
        height: 60px;
        animation: smokeRiseContinuous 3.4s infinite linear;
        animation-delay: 1.5s;
    }

    /* Thêm hạt khói mới p5 để dày hơn */
    .smoke-particle.p5 {
        width: 55px;
        height: 55px;
        background: rgba(110, 110, 110, 0.75);
        animation: smokeRiseContinuous 2.9s infinite linear;
        animation-delay: 2s;
        left: 40%; /* Lệch sang trái một chút */
    }

    /* Thêm hạt khói mới p6 để dày hơn */
    .smoke-particle.p6 {
        width: 65px;
        height: 65px;
        background: rgba(70, 70, 70, 0.8);
        animation: smokeRiseContinuous 3.6s infinite linear;
        animation-delay: 2.5s;
        left: 60%; /* Lệch sang phải một chút */
    }

/* --- HOẠT HỌA KHÓI BAY TỰ NHIÊN - TỐI ƯU ĐỘ NỞ --- */
@keyframes smokeRiseContinuous {
    0% {
        bottom: 0;
        transform: translateX(-50%) scale(0.5); /* Bắt đầu nhỏ */
        opacity: 0;
    }

    10% {
        opacity: 0.9; /* Hiện rõ nhanh chóng */
    }

    50% {
        /* Nở to hơn (scale 2.5 -> 3.0), giữ độ đậm lâu hơn, dạt sang trái */
        transform: translateX(-80px) scale(3.0);
        background: rgba(120, 70, 70, 0.5); /* Giữ ánh lửa rõ hơn */
        opacity: 0.6; /* Vẫn còn khá rõ */
    }

    80% {
        /* Nở cực đại (scale 3.5 -> 4.5), uốn lượn sang phải */
        transform: translateX(40px) scale(4.5);
        opacity: 0.2; /* Bắt đầu mờ dần */
    }

    100% {
        /* Bay cao hơn (bottom 140 -> 190), tan biến */
        bottom: 190px;
        transform: translateX(10px) scale(5.5);
        opacity: 0;
        filter: blur(20px); /* Tan biến mờ ảo */
    }
}





/* Responsive */
@media (max-width: 900px) {
    .dashboard {
        grid-template-columns: 1fr;
        /* Giới hạn chiều cao dashboard, trừ đi 160px của footer và padding */
        height: calc(100vh - 180px);
        margin-top: -80px; /* Kéo nhẹ lên trên để cân đối màn hình */
        overflow-y: auto;
        padding: 25px; /* Giảm padding trên mobile để có thêm không gian */
    }

    .title-glow {
        font-size: 2.2rem; /* Thu nhỏ tiêu đề một chút */
    }

    .terminal {
        height: 250px; /* Fix cứng chiều cao terminal trên mobile để dễ cuộn */
    }
    /* Tinh chỉnh lại scale của Footer trên mobile để không bị tràn màn hình ngang */
    .hologram-contacts {
        bottom: 80px;
        padding: 10px 15px;
        gap: 10px;
        flex-wrap: wrap; /* Cho phép các nút rớt dòng nếu màn hình quá nhỏ */
        justify-content: center;
        width: 95%; /* Tránh việc bị tràn viền 2 bên */
    }

    .state-ready .hologram-contacts {
        transform: translate(-50%, 0) scale(0.85); /* Thu nhỏ toàn bộ bảng liên hệ 15% trên mobile */
    }

    .hologram-title {
        width: 100%;
        text-align: center;
        border-right: none;
        border-bottom: 1px solid #334155;
        padding-right: 0;
        padding-bottom: 5px;
        margin-bottom: 5px;
    }
}

/* Container chứa cụm đèn */
.traffic-light-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 25px auto;
    background: #222;
    padding: 10px 20px;
    border-radius: 30px;
    width: max-content;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Style chung cho các bóng đèn */
.light {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #333; /* Trạng thái tắt */
    transition: all 0.3s ease;
}

    /* Đèn đỏ và xanh ở trạng thái tắt (tối màu) */
    .light.red {
        background-color: #500;
    }

    .light.green {
        background-color: #050;
    }

    /* Đèn vàng nhấp nháy */
    .light.yellow.flashing {
        background-color: #ffb300;
        animation: yellow-glow 1s infinite alternate;
    }

@keyframes yellow-glow {
    from {
        opacity: 0.4;
        box-shadow: 0 0 4px #ffb300;
    }

    to {
        opacity: 1;
        box-shadow: 0 0 16px #ffb300, 0 0 25px #ffb300;
    }
}
