* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, #e10707, #8b0000);
    color: #fff;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.chat-container {
    width: 100%;
    max-width: 1000px;
    height: calc(100dvh - 32px);
    max-height: 900px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #1e1e1e;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.encabezado { text-align: center; margin-bottom: 12px; }
.encabezado img { display: block; margin: 0 auto; }
.encabezado h1 { margin: 6px 0 0; font-size: 1.9rem; letter-spacing: 2px; }
.encabezado h2 { margin: 2px 0 0; font-size: 1.2rem; font-weight: 500; }
.description { margin: 8px 0 0; color: #bbb; }

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 75%;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.message a { color: #9cc7ff; }
.user-message { align-self: flex-end; background: #0d6efd; }
.bot-message { align-self: flex-start; background: #333; }
.bot-message.pensando { color: #bbb; font-style: italic; }
.bot-message.pensando::after {
    content: "";
    display: inline-block;
    width: 1em;
    text-align: left;
    animation: puntos 1.2s steps(4) infinite;
}
@keyframes puntos {
    0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}

.input-container { display: flex; gap: 10px; margin-top: 10px; }

.campo {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    font-size: 1rem;
    color: #000;
    background: #fffdfd;
    border: none;
    border-radius: 8px;
    outline: none;
}
.campo:disabled { background: #ddd; }

.boton {
    flex: none;
    width: 48px;
    font-size: 1.2rem;
    color: #fff;
    background: #0d6efd;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.boton:hover:not(:disabled) { background: #0b5ed7; }
.boton:disabled { opacity: 0.6; cursor: default; }
.boton.grabando { background: #dc3545; opacity: 1; }
.boton[hidden] { display: none; }

.insignia-admin {
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
    padding: 2px 8px;
    font-size: 0.7rem;
    letter-spacing: 1px;
    background: #198754;
    border-radius: 6px;
}
.insignia-admin[hidden] { display: none; }

.message.sistema {
    align-self: center;
    max-width: 90%;
    background: transparent;
    color: #bbb;
    font-size: 0.9rem;
    text-align: center;
}

.modal-fondo {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.65);
    z-index: 10;
}
.modal-fondo[hidden] { display: none; }
.modal {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.modal h3 { margin: 0; }
.modal label { font-size: 0.9rem; color: #ccc; margin-top: 4px; }
.modal-ayuda { margin: 0 0 4px; font-size: 0.85rem; color: #aaa; }
.modal-error { margin: 4px 0 0; color: #ff8a8a; font-size: 0.9rem; }
.modal-error[hidden] { display: none; }
.modal-botones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.boton-texto {
    padding: 8px 16px;
    font-size: 0.95rem;
    color: #fff;
    background: #0d6efd;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.boton-texto.secundario { background: #444; }
.boton-texto:disabled { opacity: 0.6; cursor: default; }

@media (max-width: 600px) {
    body { padding: 0; }
    .chat-container { height: 100dvh; max-height: none; border-radius: 0; padding: 12px; }
    .encabezado img { width: 56px; height: 56px; }
    .encabezado h1 { font-size: 1.5rem; }
    .encabezado h2, .description { display: none; }
    .message { max-width: 90%; }
}
