:root {
    --red: #e30613;
    --red-dark: #c80510;
    --black: #111111;
    --white: #ffffff;
    --background: #f1f3f6;
    --border: #e2e4e7;
    --text: #202124;
    --muted: #85898e;
    --green: #18b889;
}


/* =========================================
   BASE
========================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


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


body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    background: var(--background);
    color: var(--text);

    overflow: hidden;
}


/* =========================================
   APLICACIÓN
========================================= */

.app {
    width: 100%;
    max-width: 520px;

    height: 100vh;
    height: 100dvh;

    margin: 0 auto;

    display: flex;
    flex-direction: column;

    background: var(--white);

    overflow: hidden;
}


/* =========================================
   ENCABEZADO
========================================= */

.header {
    flex-shrink: 0;

    text-align: center;

    padding: 12px 15px 9px;

    background: var(--white);

    border-bottom: 1px solid var(--border);
}


.avatar-wrap {
    display: flex;
    justify-content: center;

    margin-bottom: 5px;
}


.avatar {
    width: 92px;
    height: 92px;

    object-fit: cover;

    border-radius: 50%;

    border: 4px solid white;

    box-shadow:
        0 0 0 1px #eeeeee,
        0 6px 20px rgba(227, 6, 19, .18);
}


.header h1 {
    margin: 2px 0 2px;

    font-size: 25px;
    line-height: 1.15;

    font-weight: 700;
}


.header h1 span {
    color: var(--red);
}


.status {
    display: flex;

    justify-content: center;
    align-items: center;

    gap: 6px;

    font-size: 14px;

    font-weight: 600;

    color: var(--green);
}


.status-dot {
    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: var(--green);
}


.subtitle {
    margin-top: 2px;

    font-size: 13px;

    color: var(--muted);
}


/* =========================================
   BOTONES RÁPIDOS
========================================= */

.quick-actions {
    flex-shrink: 0;

    display: flex;

    justify-content: center;
    align-items: center;

    gap: 6px;

    padding: 8px;

    background: var(--white);

    border-bottom: 1px solid var(--border);

    overflow: hidden;
}


.quick-button {
    height: 40px;

    flex: 1;

    min-width: 0;

    border: 1px solid #dedfe2;

    border-radius: 11px;

    background: #f7f7f8;

    color: var(--text);

    display: flex;

    align-items: center;
    justify-content: center;

    gap: 5px;

    padding: 0 6px;

    font-family: inherit;

    font-size: 12px;

    font-weight: 600;

    white-space: nowrap;

    cursor: pointer;

    transition:
        background .18s ease,
        color .18s ease,
        border-color .18s ease,
        transform .18s ease;
}


.quick-button:hover {
    background: var(--red);

    border-color: var(--red);

    color: white;
}


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


.quick-icon {
    width: 18px;
    height: 18px;

    display: flex;

    align-items: center;
    justify-content: center;

    flex-shrink: 0;
}


.quick-icon svg {
    width: 18px;
    height: 18px;

    fill: currentColor;
}


.quick-text {
    line-height: 1;
}


/* =========================================
   ÁREA DEL CHAT
========================================= */

.chat {
    flex: 1;

    min-height: 0;

    display: flex;

    flex-direction: column;

    background: var(--background);
}


#messages {
    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 14px 13px 10px;

    scroll-behavior: smooth;
}


#messages::-webkit-scrollbar {
    width: 5px;
}


#messages::-webkit-scrollbar-thumb {
    background: #cfd2d6;

    border-radius: 10px;
}


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

.msg {
    max-width: 86%;

    margin-bottom: 9px;

    padding: 10px 13px;

    border-radius: 16px;

    font-size: 15px;

    line-height: 1.5;

    word-wrap: break-word;

    animation: messageIn .2s ease;
}


.msg.bot {
    background: white;

    border: 1px solid #e5e6e8;

    border-bottom-left-radius: 5px;

    box-shadow:
        0 2px 7px rgba(0, 0, 0, .04);
}


.msg.user {
    margin-left: auto;

    background: var(--red);

    color: white;

    border-bottom-right-radius: 5px;

    box-shadow:
        0 3px 9px rgba(227, 6, 19, .16);
}


/* =========================================
   ALMA ESCRIBIENDO
========================================= */

.typing {
    width: 150px;

    color: #777;

    font-size: 13px;
}


.typing span {
    font-size: 17px;

    animation: blink 1.2s infinite;
}


.typing span:nth-child(2) {
    animation-delay: .2s;
}


.typing span:nth-child(3) {
    animation-delay: .4s;
}


/* =========================================
   ÁREA DE ESCRITURA
========================================= */

.input-area {
    flex-shrink: 0;

    padding:
        8px
        9px
        calc(7px + env(safe-area-inset-bottom));

    background: white;

    border-top: 1px solid var(--border);
}


.input-box {
    width: 100%;

    min-height: 50px;

    display: flex;

    flex-direction: row;

    flex-wrap: nowrap;

    align-items: center;

    gap: 6px;

    padding: 4px 5px 4px 14px;

    background: #f1f2f4;

    border: 1px solid #e0e1e4;

    border-radius: 26px;
}


/* =========================================
   CAMPO DE TEXTO
========================================= */

textarea {
    flex: 1 1 auto;

    width: 0;

    min-width: 0;

    height: 40px;

    min-height: 40px;

    max-height: 90px;

    padding: 9px 0;

    margin: 0;

    border: none;

    outline: none;

    resize: none;

    overflow-y: auto;

    background: transparent;

    color: var(--text);

    font-family: inherit;

    font-size: 15px;

    line-height: 21px;
}


textarea::placeholder {
    color: #999da2;
}


textarea:focus {
    outline: none;
}


/* =========================================
   MICRÓFONO
========================================= */

.mic {
    width: 40px;
    height: 40px;

    flex: 0 0 40px;

    border: none;

    border-radius: 50%;

    background: var(--black);

    color: white;

    display: flex;

    align-items: center;
    justify-content: center;

    cursor: pointer;

    transition:
        transform .18s ease,
        background .18s ease;
}


.mic:hover {
    background: #2a2a2a;

    transform: scale(1.05);
}


.mic:active {
    transform: scale(.94);
}


.mic svg {
    width: 21px;
    height: 21px;

    fill: currentColor;
}


/* =========================================
   BOTÓN ENVIAR
========================================= */

.send {
    width: 40px;
    height: 40px;

    flex: 0 0 40px;

    border: none;

    border-radius: 50%;

    background: var(--red);

    color: white;

    display: flex;

    align-items: center;
    justify-content: center;

    cursor: pointer;

    transition:
        transform .18s ease,
        background .18s ease;
}


.send:hover {
    background: var(--red-dark);

    transform: scale(1.05);
}


.send:active {
    transform: scale(.94);
}


.send svg {
    width: 21px;
    height: 21px;

    fill: currentColor;
}


/* =========================================
   TEXTO DE AYUDA
========================================= */

.input-hint {
    text-align: center;

    font-size: 11px;

    color: #888c91;

    padding-top: 5px;

    line-height: 1.3;
}


/* =========================================
   VIDEO
========================================= */

.video-modal {
    position: fixed;

    inset: 0;

    z-index: 1000;

    display: none;

    align-items: center;
    justify-content: center;

    padding: 18px;

    background: rgba(0, 0, 0, .78);
}


.video-container {
    position: relative;

    width: 100%;

    max-width: 850px;

    aspect-ratio: 16 / 9;

    background: #000;

    border-radius: 14px;

    overflow: hidden;
}


.video-container iframe {
    width: 100%;
    height: 100%;

    border: none;
}


.close-video {
    position: absolute;

    top: 8px;
    right: 8px;

    z-index: 5;

    width: 36px;
    height: 36px;

    border: none;

    border-radius: 50%;

    background: rgba(0, 0, 0, .7);

    color: white;

    display: flex;

    align-items: center;
    justify-content: center;

    cursor: pointer;
}


.close-video svg {
    width: 20px;
    height: 20px;

    fill: currentColor;
}


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

@keyframes messageIn {

    from {
        opacity: 0;
        transform: translateY(5px);
    }

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


@keyframes blink {

    0% {
        opacity: .25;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: .25;
    }
}


/* =========================================
   CELULARES
========================================= */

@media (max-width: 520px) {

    .app {
        width: 100%;
        max-width: 100%;

        height: 100vh;
        height: 100dvh;
    }


    .header {
        padding:
            10px
            12px
            8px;
    }


    .avatar {
        width: 88px;
        height: 88px;
    }


    .header h1 {
        font-size: 24px;
    }


    .subtitle {
        font-size: 12px;
    }


    .quick-actions {
        gap: 5px;

        padding:
            7px
            6px;
    }


    .quick-button {
        height: 38px;

        padding: 0 5px;

        gap: 4px;

        font-size: 11px;
    }


    .quick-icon,
    .quick-icon svg {
        width: 17px;
        height: 17px;
    }


    #messages {
        padding:
            12px
            10px
            8px;
    }


    .msg {
        max-width: 88%;

        font-size: 14px;

        padding:
            9px
            12px;
    }


    .input-area {
        padding:
            7px
            7px
            calc(7px + env(safe-area-inset-bottom));
    }


    .input-box {
        min-height: 49px;
    }


    textarea {
        font-size: 15px;
    }


    .mic,
    .send {
        width: 39px;
        height: 39px;

        flex-basis: 39px;
    }


    .mic svg,
    .send svg {
        width: 20px;
        height: 20px;
    }


    .input-hint {
        font-size: 10px;

        padding-top: 4px;
    }
}


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

@media (max-width: 380px) {

    .header {
        padding-top: 7px;
        padding-bottom: 6px;
    }


    .avatar {
        width: 76px;
        height: 76px;
    }


    .avatar-wrap {
        margin-bottom: 3px;
    }


    .header h1 {
        font-size: 22px;
    }


    .status {
        font-size: 12px;
    }


    .subtitle {
        font-size: 11px;
    }


    .quick-actions {
        gap: 3px;

        padding:
            5px
            4px;
    }


    .quick-button {
        height: 35px;

        font-size: 10px;

        gap: 2px;
    }


    .quick-icon,
    .quick-icon svg {
        width: 15px;
        height: 15px;
    }


    .msg {
        max-width: 91%;

        font-size: 13px;
    }


    .input-box {
        min-height: 47px;
    }


    .mic,
    .send {
        width: 37px;
        height: 37px;

        flex-basis: 37px;
    }
}


/* =========================================
   TABLETS
========================================= */

@media (min-width: 521px) and (max-width: 900px) {

    .app {
        max-width: 600px;
    }


    .avatar {
        width: 100px;
        height: 100px;
    }


    .quick-button {
        height: 43px;

        font-size: 13px;
    }


    #messages {
        padding: 18px;
    }


    .msg {
        font-size: 15px;
    }
}


/* =========================================
   COMPUTADORAS
========================================= */

@media (min-width: 901px) {

    body {
        display: flex;

        align-items: center;
        justify-content: center;
    }


    .app {
        width: 460px;

        height: 94vh;

        max-height: 900px;

        border-radius: 18px;

        box-shadow:
            0 15px 50px rgba(0, 0, 0, .14);

        overflow: hidden;
    }


    .header {
        padding-top: 14px;
    }


    .avatar {
        width: 95px;
        height: 95px;
    }
}


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

@media (max-height: 500px) and (orientation: landscape) {

    .header {
        padding:
            5px
            10px;
    }


    .avatar {
        width: 55px;
        height: 55px;
    }


    .avatar-wrap {
        margin-bottom: 2px;
    }


    .header h1 {
        font-size: 19px;
    }


    .status {
        font-size: 11px;
    }


    .subtitle {
        display: none;
    }


    .quick-actions {
        padding:
            4px
            6px;
    }


    .quick-button {
        height: 32px;

        font-size: 10px;
    }


    #messages {
        padding: 8px;
    }


    .msg {
        margin-bottom: 6px;

        padding:
            7px
            10px;

        font-size: 13px;
    }


    .input-area {
        padding: 5px;
    }


    .input-box {
        min-height: 43px;
    }


    .mic,
    .send {
        width: 35px;
        height: 35px;

        flex-basis: 35px;
    }


    .input-hint {
        display: none;
    }
}