* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: transparent;
}

/* BOTÓN */
#chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 9999;
}

#chat-toggle img {
    width: 50px;
    margin-left: -2px;
    margin-top: 2px;
}

/* WRAPPER */
#chat-wrapper {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 480px;
    height: 620px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 110px);
    z-index: 9998;
    transition: all 0.3s ease;
}

.hidden {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

/* CONTENEDOR */
.container {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 12px;
    border: 2px solid #e44c42;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    overflow: hidden;
}

/* HEADER */
.header {
    position: relative;
    display: flex;
    align-items: center;
    padding: 15px 5px;
    background: #fff;
}

.logo-left {
    height: 32px;
}

.title-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    height: 28px;
}

/* BOTONES DEL HEADER: ampliar/restaurar + minimizar (ademas del propio icono flotante) */
.minimize-btn,
.maximize-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #e44c42;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.minimize-btn:hover,
.maximize-btn:hover {
    background: #f0f0f0;
    color: #888;
}

.minimize-btn { right: 12px; }
.maximize-btn { right: 44px; }

/* Tamano ampliado del panel, alternado con el boton de ampliar/restaurar */
#chat-wrapper.maximized {
    width: 700px;
    height: 820px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 110px);
}

/* SUBHEADER */
.subheader {
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: #e44c42;
    border-bottom: 2px solid #e44c42;
    padding-bottom: 6px;
    text-transform: uppercase;
}

/* CHAT */
#chat {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #fff;
}

/* MENSAJES */
.msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 10px 0;
}

.msg-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
}

/* USER */
.user .msg-content {
    background: #e44c42;
    color: white;
    margin-left: auto;
}

/* BOT */
.bot .msg-content {
    background: #e9ecef;
}

.bot img {
    height: 22px;
}

/* INPUT */
.input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid #eee;
}

#msg {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
}

/* BOTÓN */
button {
    margin-left: 10px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: #e44c42;
    color: white;
    cursor: pointer;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* IMAGEN ASOCIADA A LA RESPUESTA (ver GESGRAPH-AI_IMAGENES.md) */
.chat-thumb {
    display: block;
    max-width: 160px;
    max-height: 110px;
    border-radius: 8px;
    margin-top: 6px;
    cursor: pointer;
    object-fit: cover;
}

.image-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    cursor: pointer;
}

.image-modal-full {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
}

/* PREGUNTA SÍ/NO DENTRO DEL CHAT (continuar historial previo, etc) */
.prompt-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.prompt-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    margin-left: 0;
}

.prompt-btn-yes {
    background: #e44c42;
    color: white;
}

.prompt-btn-no {
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
}

.prompt-chosen {
    display: block;
    margin-top: 6px;
    color: #888;
    font-style: italic;
}

/* AVISO MODO ENTRENAMIENTO (informativo, sin control de usuario) */
.training-banner .msg-content {
    background: #fff3cd;
    color: #664d03;
    font-size: 12px;
    max-width: 100%;
}

/* TYPING */
.typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: blink 1.4s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0% { background: #ccc; }
    50% { background: #333; }
    100% { background: #ccc; }
}