/* =========================================================
   AURORA PSP — INTERFAZ RESPONSIVA
   Diseño neon inspirado en la referencia proporcionada.
   ========================================================= */

:root {
    --bg-1: #010617;
    --bg-2: #030b22;
    --text: #f7f8ff;
    --muted: #aeb8d0;
    --purple: #a52cff;
    --blue: #3977ff;
    --cyan: #09d8ff;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    color: var(--text);
    font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background:
        radial-gradient(circle at 50% 10%, rgba(25, 75, 190, .18), transparent 28%),
        radial-gradient(circle at 15% 60%, rgba(109, 28, 255, .13), transparent 32%),
        radial-gradient(circle at 85% 60%, rgba(0, 198, 255, .11), transparent 32%),
        linear-gradient(135deg, var(--bg-1), var(--bg-2) 52%, #02091d);
}

/* =========================================================
   CONTENEDOR PRINCIPAL
   ========================================================= */

.chat-container {
    position: relative;
    width: min(1160px, calc(100vw - 40px));
    height: min(800px, calc(100vh - 50px));
    margin: 20px auto;
    padding: 18px 26px 20px;

    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;

    border: 2px solid rgba(119, 138, 208, .34);
    border-radius: 32px;

    background:
        radial-gradient(circle at 50% 15%, rgba(12, 48, 120, .10), transparent 35%),
        rgba(1, 7, 24, .76);

    box-shadow:
        0 30px 100px rgba(0, 0, 0, .52),
        inset 0 0 70px rgba(25, 55, 130, .07);

    backdrop-filter: blur(18px);
}

.chat-container::before {
    content: "";
    position: absolute;
    width: 620px;
    height: 220px;
    left: 50%;
    top: -120px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(35, 90, 255, .18), transparent 68%);
    pointer-events: none;
}

/* =========================================================
   IDENTIDAD
   ========================================================= */

.header {
    position: relative;
    z-index: 2;

    flex: 0 0 clamp(140px, 2vh, 220px);
    min-height: 0;

    padding: 6px 10px 12px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    text-align: center;
    background: transparent;
}

.avatar-header {
    width: clamp(55px, 8vw, 80px);
    height: clamp(55px, 8vw, 80px);
    margin: 0 0 7px;

    object-fit: contain;
    border-radius: 0;

    filter:
        drop-shadow(0 0 10px rgba(0, 194, 255, .48))
        drop-shadow(0 0 22px rgba(128, 39, 255, .35));
}

.header-text {
    width: 100%;
    line-height: 1.15;
}

.header-text strong {
    display: block;
    margin: 0;

    /* REDUCIDO: el nombre ya no domina toda la pantalla */
    font-size: clamp(18px, 3.2vw, 18px);
    letter-spacing: clamp(2px, .45vw, 5px);
    font-weight: 700;
    line-height: 1;

    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, .08);
}

.header-text span {
    display: block;
    width: min(100%, 680px);
    margin: 9px auto 0;

    color: #b9c0d4;
    font-size: clamp(12px, 1.35vw, 17px);
    font-weight: 400;
    line-height: 1.35;
}

/* =========================================================
   CAJA DE CHAT
   ========================================================= */

#chat {
    position: relative;
    z-index: 2;

    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;

    overflow-x: hidden;
    overflow-y: auto;

    padding: 20px 24px;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    border: 0;
    border-radius: 0;

    background: transparent;

    box-shadow: none;
}

#chat::before {
    display: none;
}

/* Partículas: ahora quedan RECORTADAS dentro de la caja */
#chat::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -70px;
    height: 170px;

    pointer-events: none;
    opacity: .45;

    background:
        radial-gradient(circle, rgba(183, 44, 255, .90) 1px, transparent 1.5px) 0 40px / 13px 13px,
        radial-gradient(circle, rgba(0, 207, 255, .85) 1px, transparent 1.5px) 100% 15px / 13px 13px;

    mask-image: linear-gradient(to top, #000, transparent 78%);
    transform: perspective(300px) rotateX(54deg);
}

/* Scrollbar */
#chat::-webkit-scrollbar {
    width: 6px;
}

#chat::-webkit-scrollbar-track {
    background: transparent;
}

#chat::-webkit-scrollbar-thumb {
    border-radius: 20px;
    background: rgba(125, 91, 255, .45);
}

/* =========================================================
   MENSAJES
   ========================================================= */

.msg {
    position: relative;
    z-index: 3;

    width: fit-content;
    max-width: min(78%, 760px);
    min-width: 120px;

    margin: 8px 0;
    padding: 13px 17px;

    border-radius: 18px;

    font-size: 15px;
    line-height: 1.5;

    overflow-wrap: anywhere;
    word-break: normal;
    white-space: pre-wrap;

    animation: messageIn .25s ease-out;
}

.user {
    align-self: flex-end;

    color: #fff;

    border: 1px solid rgba(72, 154, 255, .40);
    border-bottom-right-radius: 5px;

    background: linear-gradient(
        135deg,
        rgba(84, 48, 202, .86),
        rgba(22, 104, 208, .82)
    );

    box-shadow: 0 8px 25px rgba(45, 56, 180, .18);
}

.bot {
    align-self: flex-start;

    color: #e9edfa;

    border: 1px solid rgba(99, 123, 190, .22);
    border-bottom-left-radius: 5px;

    background: rgba(16, 27, 58, .82);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
}

/* Bienvenida */
.welcome {
    width: auto;
    max-width: 100%;
    min-width: 0;

    margin: 0;
    padding: 8px 8px 8px 64px;

    border: 0;
    border-radius: 0;

    background: transparent;
    color: #f2f4fb;

    font-size: clamp(12px, 1.2vw, 17px);
    line-height: 1.35;

    box-shadow: none;
}

.welcome::before {
    content: "✦";

    position: absolute;
    left: 0;
    top: 3px;

    width: 44px;
    height: 44px;

    display: grid;
    place-items: center;

    border: 1px solid rgba(166, 49, 255, .60);
    border-radius: 50%;

    color: #fff;
    font-size: 23px;

    background: radial-gradient(
        circle,
        rgba(173, 38, 255, .62),
        rgba(42, 19, 91, .22)
    );

    box-shadow:
        0 0 16px rgba(162, 40, 255, .38),
        inset 0 0 15px rgba(194, 58, 255, .18);
}

.bot button {
    margin-top: 10px !important;
}

/* =========================================================
   BARRA DE PREGUNTA
   ========================================================= */

.input-area {
    position: relative;
    z-index: 4;

    flex: 0 0 68px;
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 9px;

    margin-top: 16px;
    padding: 5px 7px 5px 10px;

    border: 1px solid transparent;
    border-radius: 38px;

    background:
        linear-gradient(rgba(3, 10, 32, .96), rgba(3, 10, 32, .96)) padding-box,
        linear-gradient(100deg, #9d2aff, #4168ff 48%, #00d8ff) border-box;

    box-shadow:
        0 0 22px rgba(105, 48, 255, .18),
        inset 0 0 28px rgba(22, 66, 155, .12);
}

input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 54px;

    padding: 0 8px;

    border: 0;
    outline: none;

    background: transparent;
    color: #fff;

    font: inherit;
    font-size: 16px;
}

input::placeholder {
    color: #7f89a3;
}

/* Botones */
button {
    border: 0;
    outline: none;

    color: #fff;
    cursor: pointer;

    font: inherit;
    flex-shrink: 0;

    transition:
        transform .2s ease,
        box-shadow .2s ease,
        filter .2s ease;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

button:active {
    transform: scale(.96);
}

/* Micrófono */
#voiceBtn {
    width: 54px;
    height: 54px;

    margin: 0;

    display: grid;
    place-items: center;

    border-radius: 50%;

    font-size: 23px;

    background: linear-gradient(135deg, #9227ff, #00bde9);

    box-shadow:
        0 0 18px rgba(85, 75, 255, .62),
        inset 0 0 12px rgba(255, 255, 255, .16);
}

#voiceBtn.recording {
    animation: pulse 1s infinite;

    box-shadow:
        0 0 25px rgba(255, 65, 218, .78),
        0 0 45px rgba(66, 117, 255, .30);
}

/* Brillo */
#sparkleBtn {
    width: 48px;
    height: 54px;

    margin-left: auto;

    display: grid;
    place-items: center;

    border-left: 1px solid rgba(99, 120, 180, .18);
    border-radius: 50%;

    background: transparent;
    color: #fff;

    font-size: 25px;
}

/* Enviar */
#sendBtn {
    width: 54px;
    height: 54px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    font-size: 26px;

    background: linear-gradient(135deg, #9227ff, #00bde9);

    box-shadow:
        0 0 20px rgba(53, 145, 255, .50),
        inset 0 0 10px rgba(255, 255, 255, .12);
}

/* Copiar */
.copy-btn {
    width: auto;
    height: auto;

    padding: 6px 10px;

    border: 1px solid rgba(116, 139, 205, .26);
    border-radius: 10px;

    background: rgba(31, 48, 91, .65);
    color: #bfc9e5;

    font-size: 12px;
}

/* =========================================================
   ANIMACIONES
   ========================================================= */

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.10);
    }
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

/* =========================================================
   TABLET / LAPTOP PEQUEÑA
   ========================================================= */

@media (max-width: 900px) {
    .chat-container {
        width: calc(100vw - 24px);
        height: calc(100vh - 24px);
        margin: 12px auto;
        padding: 14px 18px 16px;
        border-radius: 26px;
    }

    .header {
        flex-basis: clamp(170px, 27vh, 220px);
    }

    .avatar-header {
        width: clamp(58px, 10vw, 78px);
        height: clamp(58px, 10vw, 78px);
    }

    .header-text strong {
        font-size: clamp(25px, 4vw, 35px);
    }

    .header-text span {
        font-size: 13px;
        max-width: 560px;
    }

    #chat {
        padding: 17px 18px;
        border-radius: 25px;
    }

    .input-area {
        margin-top: 12px;
        flex-basis: 64px;
    }

    input {
        font-size: 15px;
    }

    #voiceBtn,
    #sendBtn {
        width: 50px;
        height: 50px;
    }

    #sparkleBtn {
        width: 44px;
        height: 50px;
    }
}

/* =========================================================
   CELULAR
   ========================================================= */

@media (max-width: 600px) {
    body {
        overflow: hidden;
    }

    .chat-container {
        width: 100vw;
        height: 100dvh;

        margin: 0;
        padding: 10px 10px 10px;

        border: 0;
        border-radius: 0;
    }

    .chat-container::before {
        width: 100%;
        height: 160px;
        top: -80px;
    }

    .header {
        flex: 0 0 165px;
        padding: 2px 4px 8px;
    }

    .avatar-header {
        width: 62px;
        height: 62px;
        margin-bottom: 5px;
    }

    .header-text strong {
        font-size: 25px;
        letter-spacing: 2.5px;
    }

    .header-text span {
        margin-top: 7px;
        max-width: 95%;
        font-size: 11.5px;
        line-height: 1.3;
    }

    #chat {
        padding: 14px 14px;
        border-radius: 23px;
    }

    .msg {
        max-width: 88%;
        min-width: 90px;
        padding: 10px 13px;
        font-size: 13.5px;
    }

    .welcome {
        padding: 7px 6px 7px 54px;
        font-size: 18px;
    }

    .welcome::before {
        width: 39px;
        height: 39px;
        font-size: 20px;
    }

    .input-area {
        flex: 0 0 60px;
        margin-top: 10px;
        gap: 5px;
        padding: 3px 5px 3px 7px;
        border-radius: 34px;
    }

    input {
        height: 50px;
        padding: 0 5px;
        font-size: 14px;
    }

    #voiceBtn,
    #sendBtn {
        width: 48px;
        height: 48px;
    }

    #voiceBtn {
        font-size: 21px;
    }

    #sendBtn {
        font-size: 23px;
    }

    #sparkleBtn {
        width: 39px;
        height: 48px;
        font-size: 21px;
    }
}

/* =========================================================
   CELULARES MUY PEQUEÑOS
   ========================================================= */

@media (max-width: 390px) {
    .chat-container {
        padding: 7px;
    }

    .header {
        flex-basis: 145px;
    }

    .avatar-header {
        width: 54px;
        height: 54px;
    }

    .header-text strong {
        font-size: 22px;
        letter-spacing: 2px;
    }

    .header-text span {
        font-size: 10.5px;
    }

    #chat {
        padding: 12px;
        border-radius: 0;
    }

    .input-area {
        flex-basis: 56px;
    }

    #sparkleBtn {
        display: none;
    }
}


#chat::after {
    display: none !important;
}


/* =========================================================
   ARCHIVO TXT — AURORA PSP
   ========================================================= */

#uploadTxtBtn {
    width: 42px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: transparent;
    color: #9eb8dc;
    font-size: 20px;
}

#uploadTxtBtn:hover {
    color: #70cfff;
    background: rgba(37, 120, 190, .10);
}

#uploadTxtBtn.attached {
    color: #65d7ff;
    text-shadow: 0 0 10px rgba(70, 190, 255, .35);
}

@media (max-width: 600px) {
    #uploadTxtBtn {
        width: 38px;
        height: 48px;
        font-size: 19px;
    }
}

@media (max-width: 390px) {
    #uploadTxtBtn {
        width: 34px;
        height: 46px;
        font-size: 18px;
    }
}


/* =========================================================
   ACCIONES DE RESPUESTA — ESCUCHAR / COPIAR
   ========================================================= */

.message-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
}

.message-actions button {
    margin-top: 0 !important;
}

.speak-btn {
    width: auto;
    height: auto;
    padding: 6px 10px;
    border: 1px solid rgba(0, 216, 255, .28);
    border-radius: 10px;
    background: rgba(20, 65, 91, .58);
    color: #bfeeff;
    font-size: 12px;
}

.speak-btn:hover {
    background: rgba(20, 92, 124, .72);
}

.speak-btn.speaking {
    border-color: rgba(165, 44, 255, .62);
    box-shadow: 0 0 12px rgba(165, 44, 255, .28);
}

.speak-btn:disabled {
    cursor: wait;
    opacity: .75;
}

@media (max-width: 600px) {
    .message-actions {
        gap: 5px;
    }

    .speak-btn,
    .copy-btn {
        font-size: 11px;
        padding: 6px 9px;
    }
}
