/* Base y fuente */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #121217;
    color: #e0e4e8;
    font-family: 'Segoe UI Variable', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    background-color: #121217;
}

/* Layout general */
.layout-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Menú lateral izquierdo */
#sidebar {
    width: 25%;
    min-width: 200px;
    background-color: #1b1d23;
    color: #ffffff;
    padding: 1.5rem 1rem;
    box-sizing: border-box;
    border-right: 1px solid #2c2e34;
    display: flex;
    flex-direction: column;
}

#sidebar h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: #5a90ff;
}

#chat-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

#chat-list li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    font-size: 0.95rem;
}

#chat-list li:hover {
    background-color: #2c2f3a;
}

#chat-list li.active {
    background-color: #3451d1;
    color: white;
    font-weight: bold;
}

/* Área principal del chat */
#main-content {
    width: 75%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.25rem 1rem;
    background-color: #121217;
    overflow: hidden;
}

/* Título */
h1 {
    text-align: center;
    margin-bottom: 1.25rem;
    color: #5a90ff;
    font-weight: 700;
    font-size: 1.75rem;
    letter-spacing: 0.05em;
    user-select: none;
}

/* Contenedor de mensajes */
#chat-log {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 1.25rem 1.5rem;
    box-sizing: border-box;
    background-color: #1a1c22;
    border-radius: 16px;
    scrollbar-width: thin;
    scrollbar-color: #5a90ff33 transparent;
}

#chat-log::-webkit-scrollbar {
    width: 6px;
}

#chat-log::-webkit-scrollbar-thumb {
    background-color: #5a90ff55;
    border-radius: 3px;
}

/* Burbujas comunes */
.bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 20px;
    line-height: 1.5;
    font-size: 1rem;
    word-wrap: break-word;
    user-select: text;
    transition: background-color 0.3s ease, color 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
    animation: slideFadeIn 0.3s forwards;
}

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

/* Burbuja del usuario */
.user {
    background-color: #3451d1;
    align-self: flex-end;
    color: #ffffff;
    border-radius: 20px 20px 4px 20px;
}

/* Burbuja del bot */
.bot {
    background-color: #2a2d35;
    align-self: flex-start;
    color: #a4c8ff;
    font-style: italic;
    border-radius: 20px 20px 20px 4px;
}

/* Formulario de entrada */
form {
    flex-shrink: 0;
    margin-top: 1.25rem;
    display: flex;
    gap: 12px;
    padding: 0;
    box-sizing: border-box;
    background: transparent;
    border-radius: 0;
}

/* Textarea */
textarea {
    flex-grow: 1;
    min-height: 4.25rem;
    border-radius: 16px;
    border: 1px solid #2d2f36;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    resize: none;
    outline: none;
    background-color: #1c1e24;
    color: #e6e9ef;
    font-family: inherit;
    max-width: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    transition: border-color 0.25s ease, background-color 0.25s ease;
}

textarea::placeholder {
    color: #6a6e7c;
    font-style: italic;
    opacity: 0.9;
}

textarea:focus {
    border-color: #5a90ff;
    background-color: #20232a;
}

/* Botón */
button#send-btn {
    background-color: #5a90ff;
    border: none;
    border-radius: 14px;
    color: #ffffff;
    padding: 0 1.75rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.25s ease, transform 0.1s ease;
    white-space: nowrap;
}

button#send-btn:hover:not(:disabled) {
    background-color: #4076e0;
}

button#send-btn:active:not(:disabled) {
    transform: translateY(1px);
    background-color: #305dc0;
}

button#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #3a4a6a;
}

#spinner {
    display: none;
    margin: 1rem auto;
    width: 36px;
    height: 36px;
    border: 4px solid rgba(90, 144, 255, 0.2);
    border-top-color: #5a90ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Texto "Pensando..." */
#thinking-text {
    text-align: center;
    color: #5a90ff;
    font-style: italic;
    margin-top: 0.5rem;
    font-weight: 600;
    display: none;
    user-select: none;
}

.timestamp {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: #999;
    margin-top: 6px;
    font-style: normal;
    opacity: 0.7;
    user-select: none;
}

#new-chat-btn {
    margin-bottom: 10px;
    padding: 8px;
    font-size: 14px;
    cursor: pointer;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#new-chat-btn:hover {
    background-color: #e0e0e0;
}

/* Responsive */
@media (max-width: 768px) {
    .layout-container {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #2c2e34;
    }

    #main-content {
        width: 100%;
    }
}