:root {
    --bg-deep: #01111F;
    --bg-panel: #01111F;
    --bg-panel-2: #01111F;
    --panel-edge: #F78F1B;
    --paper: #01111F;
    --paper-edge: #2e1a10;

    --flame-cream: #FFF4D4;
    --flame-gold-light: #FEE7A6;
    --flame-gold: #F9C44B;
    --flame-gold-soft: rgba(249, 196, 75, 0.15);
    --flame-amber: #F6A11A;
    --flame-orange: #F67A0C;
    --flame-orange-deep: #F05A07;
    --flame-red-orange: #E6400A;
    --flame-red-orange-soft: rgba(230, 64, 10, 0.15);
    --flame-red: #D82B09;
    --flame-red-deep: #B91E0B;

    --text-on-dark: var(--flame-cream);
    --text-muted: #a3876a;
    --text-body: #e8d4b3;

    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Rajdhani', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(249, 196, 75, 0.08), transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(230, 64, 10, 0.08), transparent 50%),
        var(--bg-deep);
    font-family: var(--font-body);
    color: var(--text-on-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    position: relative;
    overflow-x: hidden;
}

/* --- Fondo con grid futurista --- */
.grid-bg {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(249, 196, 75, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(249, 196, 75, 0.04) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

.scanline {
    position: fixed;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(249, 196, 75, 0.03) 50%,
        transparent 100%
    );
    background-size: 100% 8px;
    pointer-events: none;
    z-index: 1;
    animation: scan 8s linear infinite;
}

@keyframes scan {
    0% { background-position: 0 -100vh; }
    100% { background-position: 0 100vh; }
}

.page {
    width: 100%;
    max-width: 720px;
    position: relative;
    z-index: 2;
}

.page-intro {
    margin-bottom: 24px;
    padding: 0 4px;
}

.eyebrow {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--flame-gold);
    border: 1px solid var(--flame-gold);
    padding: 5px 12px;
    margin-bottom: 16px;
    background: var(--flame-gold-soft);
    box-shadow: 0 0 20px var(--flame-gold-soft), inset 0 0 10px var(--flame-gold-soft);
    clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}

.page-intro h1 {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 900;
    margin: 0 0 10px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: linear-gradient(90deg, var(--flame-gold), var(--flame-red-orange));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 40px rgba(246, 122, 12, 0.3);
}

.page-intro p {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-muted);
    margin: 0;
    max-width: 60ch;
    font-weight: 500;
}

/* --- Ticket / widget futurista --- */
.ticket {
    background: linear-gradient(135deg, var(--bg-panel) 0%, var(--bg-panel-2) 100%);
    border: 1px solid var(--panel-edge);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 640px;
    box-shadow:
        0 0 0 1px rgba(249, 196, 75, 0.1),
        0 0 40px rgba(249, 196, 75, 0.15),
        0 30px 80px rgba(0, 0, 0, 0.6);
    position: relative;
}

.ticket::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, transparent 40%, rgba(249, 196, 75, 0.03) 50%, transparent 60%);
    pointer-events: none;
    z-index: 1;
}

.ticket > * { position: relative; z-index: 2; }

.ticket-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--panel-edge);
    background: linear-gradient(180deg, rgba(249, 196, 75, 0.05), transparent);
    gap: 16px;
}

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

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--flame-gold);
    box-shadow: 0 0 10px var(--flame-gold), 0 0 20px var(--flame-gold);
    flex-shrink: 0;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

.ticket-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: var(--text-on-dark);
    letter-spacing: 0.1em;
}

.ticket-subtitle {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin: 3px 0 0;
    letter-spacing: 0.05em;
}

.ticket-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--flame-gold);
    letter-spacing: 0.15em;
    padding: 4px 10px;
    border: 1px solid rgba(249, 196, 75, 0.3);
    border-radius: 2px;
    background: rgba(249, 196, 75, 0.05);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--flame-gold);
    box-shadow: 0 0 6px var(--flame-gold);
}

.ticket-id {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--flame-amber);
    letter-spacing: 0.1em;
}

/* --- Cuerpo del chat --- */
.ticket-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-panel);
    scrollbar-width: thin;
    scrollbar-color: var(--flame-gold) transparent;
}

.ticket-body::-webkit-scrollbar { width: 6px; }
.ticket-body::-webkit-scrollbar-track { background: transparent; }
.ticket-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--flame-gold), var(--flame-red-orange));
    border-radius: 999px;
}

/* --- Mensajes --- */
.msg {
    max-width: 88%;
    animation: rise 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes rise {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.msg-user {
    align-self: flex-end;
}

.msg-user .bubble {
    background: linear-gradient(135deg, var(--flame-gold), var(--flame-orange-deep));
    color: #2b1400;
    border-radius: 16px 16px 4px 16px;
    padding: 12px 18px;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    box-shadow: 0 0 20px rgba(246, 122, 12, 0.3);
    border: 1px solid rgba(255, 244, 212, 0.25);
}

.msg-bot {
    align-self: flex-start;
    width: 90%;
}

.receipt {
    background: linear-gradient(135deg, var(--paper) 0%, #120a05 100%);
    color: var(--text-body);
    border-radius: 4px;
    position: relative;
    padding: 14px 18px 14px;
    font-size: 14.5px;
    line-height: 1.6;
    border: 1px solid var(--panel-edge);
    box-shadow:
        inset 0 0 20px rgba(249, 196, 75, 0.03),
        0 4px 20px rgba(0, 0, 0, 0.4);
    clip-path: polygon(
        0 0,
        calc(100% - 12px) 0,
        100% 12px,
        100% 100%,
        12px 100%,
        0 calc(100% - 12px)
    );
}

.receipt::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        var(--flame-gold),
        var(--flame-red-orange),
        transparent
    );
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.receipt-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--flame-gold);
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--panel-edge);
    padding-bottom: 8px;
}

.receipt-meta.no-match {
    color: var(--flame-red-orange);
}

.receipt-meta .stamp {
    font-weight: 600;
}

.receipt-question {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 0 8px;
    letter-spacing: 0.03em;
}

.receipt-answer {
    margin: 0;
    font-weight: 500;
}

.suggestions {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.suggestions button {
    width: 100%;
    text-align: left;
    background: rgba(249, 196, 75, 0.05);
    border: 1px solid var(--panel-edge);
    color: var(--text-body);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    padding: 10px 14px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.suggestions button::before {
    content: "▸ ";
    color: var(--flame-gold);
    font-family: var(--font-mono);
}

.suggestions button:hover {
    border-color: var(--flame-gold);
    background: rgba(249, 196, 75, 0.1);
    color: var(--flame-gold);
    box-shadow: 0 0 15px rgba(249, 196, 75, 0.2);
    transform: translateX(4px);
}

.suggestions button:active { transform: translateX(4px) scale(0.99); }

/* --- Typing indicator --- */
.typing {
    display: flex;
    gap: 6px;
    align-self: flex-start;
    padding: 14px 18px;
    background: var(--paper);
    border: 1px solid var(--panel-edge);
    border-radius: 4px;
}

.typing span {
    width: 8px;
    height: 8px;
    background: var(--flame-gold);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--flame-gold);
    animation: blink 1.2s infinite ease-in-out;
    opacity: 0.3;
}

.typing span:nth-child(2) { animation-delay: 0.2s; background: var(--flame-red-orange); box-shadow: 0 0 8px var(--flame-red-orange); }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* --- Input area --- */
.ticket-input-wrap {
    border-top: 1px solid var(--panel-edge);
    background: linear-gradient(180deg, transparent, rgba(249, 196, 75, 0.03));
}

.input-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 22px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.2em;
    color: var(--flame-gold);
    border-bottom: 1px dashed var(--panel-edge);
    text-transform: uppercase;
}

.input-status.listening {
    color: var(--flame-red-orange);
}

.input-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--flame-gold);
    box-shadow: 0 0 6px var(--flame-gold);
    animation: pulse-dot 2s ease-in-out infinite;
}

.input-status.listening .input-status-dot {
    background: var(--flame-red-orange);
    box-shadow: 0 0 10px var(--flame-red-orange);
    animation: pulse-dot 0.8s ease-in-out infinite;
}

.ticket-input {
    display: flex;
    gap: 10px;
    padding: 16px 22px;
    align-items: center;
}

.ticket-input input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--panel-edge);
    color: var(--text-on-dark);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 500;
    padding: 13px 18px;
    border-radius: 4px;
    outline: none;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
}

.ticket-input input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.05em;
}

.ticket-input input:focus {
    border-color: var(--flame-gold);
    box-shadow: 0 0 0 2px rgba(249, 196, 75, 0.15), 0 0 20px rgba(249, 196, 75, 0.2);
    background: rgba(249, 196, 75, 0.03);
}

/* --- Botón Micrófono --- */
.mic-btn {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: rgba(230, 64, 10, 0.08);
    color: var(--flame-red-orange);
    border: 1px solid rgba(230, 64, 10, 0.4);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    position: relative;
}

.mic-btn:hover {
    background: rgba(230, 64, 10, 0.15);
    box-shadow: 0 0 20px rgba(230, 64, 10, 0.4);
    transform: scale(1.05);
}

.mic-btn.listening {
    background: var(--flame-red-orange);
    color: #fff4d4;
    border-color: var(--flame-red-orange);
    box-shadow: 0 0 25px var(--flame-red-orange);
    animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% {
        box-shadow: 0 0 20px var(--flame-red-orange), 0 0 0 0 rgba(230, 64, 10, 0.6);
    }
    50% {
        box-shadow: 0 0 25px var(--flame-red-orange), 0 0 0 15px rgba(230, 64, 10, 0);
    }
}

.mic-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--flame-red-orange);
    opacity: 0;
    pointer-events: none;
}

.mic-btn.listening .mic-pulse {
    animation: ring-expand 1.5s ease-out infinite;
}

@keyframes ring-expand {
    0% { transform: scale(0.8); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* --- Botón Enviar --- */
.send-btn {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--flame-gold), var(--flame-orange-deep));
    color: #2b1400;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    box-shadow: 0 0 15px rgba(246, 122, 12, 0.3);
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 25px rgba(246, 122, 12, 0.5);
}

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

/* --- Focus visible --- */
.mic-btn:focus-visible,
.send-btn:focus-visible,
.suggestions button:focus-visible,
.ticket-input input:focus-visible {
    outline: 2px solid var(--flame-cream);
    outline-offset: 2px;
}

/* --- Footer info --- */
.footer-info {
    display: flex;
    justify-content: space-between;
    margin-top: 18px;
    padding: 0 4px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.2em;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* --- Efecto Glitch en título --- */
.glitch {
    position: relative;
    display: inline-block;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    background: linear-gradient(90deg, var(--flame-gold), var(--flame-red-orange));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.glitch::before {
    animation: glitch-1 3s infinite linear;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.glitch::after {
    animation: glitch-2 3s infinite linear;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

@keyframes glitch-1 {
    0%, 90%, 100% { transform: translate(0); }
    92% { transform: translate(-2px, 1px); }
    94% { transform: translate(2px, -1px); }
    96% { transform: translate(-1px, 0); }
}

@keyframes glitch-2 {
    0%, 90%, 100% { transform: translate(0); }
    91% { transform: translate(2px, -1px); }
    93% { transform: translate(-2px, 1px); }
    95% { transform: translate(1px, 0); }
}

/* --- Responsive --- */
@media (prefers-reduced-motion: reduce) {
    .msg, .typing span, .scanline, .glitch::before, .glitch::after {
        animation: none;
    }
}

@media (max-width: 760px) {
    .ticket { height: 78vh; }
    .page-intro h1 { font-size: 28px; }
    .ticket-status { display: none; }
    .footer-info { font-size: 9px; gap: 8px; flex-wrap: wrap; }
}