/* ===== CSS Variables ===== */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --accent: #06b6d4;
    --bg-dark: #0f0f23;
    --bg-darker: #070714;
    --surface: rgba(255, 255, 255, 0.03);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glow: rgba(99, 102, 241, 0.5);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* ===== Background Animation ===== */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 50%, #1a1a3e 100%);
}

.stars,
.stars2,
.stars3 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.stars {
    background:
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255, 255, 255, 0.9), transparent),
        radial-gradient(1px 1px at 230px 80px, #fff, transparent),
        radial-gradient(2px 2px at 300px 150px, rgba(255, 255, 255, 0.7), transparent),
        radial-gradient(1px 1px at 370px 50px, #fff, transparent),
        radial-gradient(2px 2px at 440px 130px, rgba(255, 255, 255, 0.8), transparent);
    background-repeat: repeat;
    background-size: 500px 200px;
    animation: twinkle 8s ease-in-out infinite;
}

.stars2 {
    background:
        radial-gradient(1px 1px at 50px 80px, rgba(255, 255, 255, 0.6), transparent),
        radial-gradient(2px 2px at 120px 20px, #fff, transparent),
        radial-gradient(1px 1px at 200px 100px, rgba(255, 255, 255, 0.7), transparent),
        radial-gradient(2px 2px at 280px 60px, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(1px 1px at 350px 140px, #fff, transparent),
        radial-gradient(2px 2px at 420px 90px, rgba(255, 255, 255, 0.8), transparent);
    background-repeat: repeat;
    background-size: 450px 180px;
    animation: twinkle 12s ease-in-out infinite 2s;
}

.stars3 {
    background:
        radial-gradient(2px 2px at 80px 60px, rgba(147, 197, 253, 0.8), transparent),
        radial-gradient(1px 1px at 180px 130px, rgba(196, 181, 253, 0.7), transparent),
        radial-gradient(2px 2px at 260px 40px, rgba(147, 197, 253, 0.6), transparent),
        radial-gradient(1px 1px at 340px 110px, rgba(196, 181, 253, 0.8), transparent);
    background-repeat: repeat;
    background-size: 400px 160px;
    animation: twinkle 15s ease-in-out infinite 4s;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===== Particles ===== */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary-light);
    border-radius: 50%;
    opacity: 0;
    animation: float-particle 15s infinite;
}

@keyframes float-particle {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateY(-100vh) scale(1);
    }
}

/* ===== Container ===== */
.container {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 1rem;
    max-width: 700px;
    width: 100%;
}

/* ===== Error Card ===== */
.error-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem 1.5rem 2rem;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 80px rgba(99, 102, 241, 0.1);
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

/* ===== Error Code (404) ===== */
.error-code {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.digit {
    font-size: clamp(4rem, 12vw, 7rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 30px var(--glow));
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 30px var(--glow));
    }

    50% {
        filter: drop-shadow(0 0 50px var(--glow)) drop-shadow(0 0 80px rgba(236, 72, 153, 0.3));
    }
}

/* Planet Zero */
.digit.zero {
    position: relative;
    width: clamp(4rem, 12vw, 7rem);
    height: clamp(4rem, 12vw, 7rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

.planet {
    width: 80%;
    height: 80%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, #3730a3 100%);
    border-radius: 50%;
    position: relative;
    box-shadow:
        inset -20px -20px 40px rgba(0, 0, 0, 0.4),
        inset 10px 10px 30px rgba(255, 255, 255, 0.1),
        0 0 60px var(--glow);
    animation: float 6s ease-in-out infinite;
}

.planet::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 20%;
    width: 15%;
    height: 15%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    filter: blur(5px);
}

.ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotateX(75deg);
    width: 140%;
    height: 140%;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    animation: rotate-ring 20s linear infinite;
}

.ring::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid rgba(99, 102, 241, 0.4);
    border-radius: 50%;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes rotate-ring {
    from {
        transform: translate(-50%, -50%) rotateX(75deg) rotateZ(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotateX(75deg) rotateZ(360deg);
    }
}

/* ===== Error Content ===== */
.error-content {
    animation: fadeIn 1s ease-out 0.3s both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.error-title {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-message {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 450px;
    margin: 0 auto 1rem;
}

/* ===== Rocket ===== */
.rocket-container {
    height: 110px;
    margin: 0.5rem 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rocket {
    position: relative;
    animation: rocket-float 4s ease-in-out infinite;
}

@keyframes rocket-float {

    0%,
    100% {
        transform: translateY(0) rotate(-8deg);
    }

    50% {
        transform: translateY(-12px) rotate(8deg);
    }
}

/* Rocket Nose/Tip */
.rocket .nose {
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 22px solid #ef4444;
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    filter: drop-shadow(0 -2px 5px rgba(239, 68, 68, 0.5));
}

.rocket .nose::after {
    content: '';
    position: absolute;
    top: 6px;
    left: -6px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 10px solid #fbbf24;
}

/* Rocket Body */
.rocket .body {
    width: 28px;
    height: 42px;
    background: linear-gradient(90deg, #d1d5db 0%, #f8fafc 30%, #f8fafc 70%, #d1d5db 100%);
    border-radius: 6px 6px 4px 4px;
    position: relative;
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.3),
        inset 2px 0 6px rgba(255, 255, 255, 0.5),
        inset -2px 0 6px rgba(0, 0, 0, 0.1);
    z-index: 3;
}

/* Stripe on body */
.rocket .body::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(90deg, #dc2626 0%, #ef4444 50%, #dc2626 100%);
    border-radius: 0 0 4px 4px;
}

/* Window */
.rocket .window {
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 50%;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow:
        0 0 12px var(--glow),
        inset 2px 2px 3px rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.4);
    z-index: 5;
}

.rocket .window::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 3px;
    height: 3px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
}

/* Fins */
.rocket .fin {
    width: 15px;
    height: 18px;
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
    position: absolute;
    bottom: -3px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.rocket .fin.left {
    left: -10px;
    border-radius: 50% 0 0 8px;
    transform: skewY(20deg);
}

.rocket .fin.right {
    right: -10px;
    border-radius: 0 50% 8px 0;
    transform: skewY(-20deg);
}

/* Flames */
.rocket .flames {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1px;
    z-index: 1;
}

.rocket .flame {
    border-radius: 50% 50% 50% 50%;
    animation: flicker 0.12s ease-in-out infinite alternate;
}

.rocket .flame.f1 {
    width: 6px;
    height: 15px;
    background: linear-gradient(180deg, #fef3c7 0%, #fbbf24 40%, #f97316 70%, #ef4444 100%);
    animation-delay: 0s;
}

.rocket .flame.f2 {
    width: 8px;
    height: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #fef3c7 20%, #fbbf24 50%, #f97316 80%, #ef4444 100%);
    animation-delay: 0.04s;
}

.rocket .flame.f3 {
    width: 6px;
    height: 15px;
    background: linear-gradient(180deg, #fef3c7 0%, #fbbf24 40%, #f97316 70%, #ef4444 100%);
    animation-delay: 0.08s;
}

@keyframes flicker {
    0% {
        transform: scaleY(1) scaleX(1);
        opacity: 1;
    }

    100% {
        transform: scaleY(1.15) scaleX(0.85);
        opacity: 0.85;
    }
}

/* ===== Buttons ===== */
.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-3px);
    border-color: var(--primary-light);
}

/* ===== Fun Fact ===== */
.fun-fact {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: fadeInUp 1s ease-out 0.6s both;
}

.fun-fact-icon {
    font-size: 1.5rem;
}

.fun-fact p {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: left;
    line-height: 1.5;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .error-card {
        padding: 2rem 1.5rem;
        border-radius: 20px;
    }

    .error-message {
        font-size: 1rem;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .fun-fact {
        flex-direction: column;
        text-align: center;
    }

    .fun-fact p {
        text-align: center;
    }

    .astronaut-container {
        height: 100px;
    }

    .astronaut {
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Selection ===== */
::selection {
    background: var(--primary);
    color: white;
}

/* ===== Credits ===== */
.credits {
    margin-top: 5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    opacity: 0.8;
}

.credits a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color 0.3s ease;
}

.credits a:hover {
    color: var(--primary);
}

/* ===== WhatsApp Button ===== */
.whatsapp-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background-color: #25D366;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
    animation: pulse-green 2s infinite;
}

.whatsapp-btn:hover {
    transform: scale(1.1);
    background-color: #128C7E;
}

.whatsapp-btn svg {
    width: 35px;
    height: 35px;
    fill: currentColor;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

/* ===== WhatsApp Message Balloon ===== */
.msg-balloon {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    color: #075e54;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    animation: tooltip-slide-in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards 1s, tooltip-float 3s ease-in-out infinite 1.5s;
    pointer-events: none;
}

.msg-balloon::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid white;
}

@keyframes tooltip-slide-in {
    from {
        opacity: 0;
        transform: translate(20px, -50%);
    }

    to {
        opacity: 1;
        transform: translate(0, -50%);
    }
}

@keyframes tooltip-float {

    0%,
    100% {
        transform: translate(0, -50%);
    }

    50% {
        transform: translate(-5px, -50%);
    }
}

/* ===== WhatsApp Chat Window ===== */
.whatsapp-chat-window {
    position: fixed;
    bottom: 110px;
    right: 2rem;
    width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.9);
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.whatsapp-chat-window.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
    background: #075e54;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
}

.chat-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
}

.chat-info {
    flex: 1;
}

.chat-title {
    display: block;
    font-weight: 600;
    font-size: 1rem;
}

.chat-status {
    display: block;
    font-size: 0.75rem;
    opacity: 0.8;
}

.close-chat {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.5rem;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.close-chat:hover {
    opacity: 1;
}

/* Chat Body */
.chat-body {
    background: #e5ddd5;
    padding: 1.5rem 1rem;
    height: 250px;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 10h10v10H10V10z' fill='%23d1d7db' fill-opacity='0.4'/%3E%3C/svg%3E");
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.message {
    max-width: 80%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message.received {
    align-self: flex-start;
    background: white;
    color: #111b21;
    border-top-left-radius: 0;
}

.message.received::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top-color: white;
    border-right-color: white;
}

.message-time {
    display: block;
    text-align: right;
    font-size: 0.65rem;
    color: #667781;
    margin-top: 0.25rem;
}

/* Chat Footer */
.chat-footer {
    background: #f0f2f5;
    padding: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-footer textarea {
    flex: 1;
    border: none;
    padding: 0.75rem;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
    height: 40px;
    line-height: 1.4;
    outline: none;
    scrollbar-width: none;
}

.send-btn {
    background: #075e54;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.send-btn:hover {
    transform: scale(1.1);
    background: #128c7e;
}

.send-btn svg {
    margin-left: 2px;
}

/* Responsive Widget */
@media (max-width: 480px) {
    .whatsapp-chat-window {
        width: calc(100% - 2rem);
        right: 1rem;
        bottom: 85px;
    }

    .whatsapp-btn {
        right: 1rem;
        bottom: 1.5rem;
    }
}