:root {
    --beige: #E0CE7C;
    --vino: #510505;
    --vino-claro: #9D1B32;
    --blanco: #FFFFFF;
    --bg: #f9f7f1;
    --text: #2d2a2a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
}

.layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 280px;
    padding: 28px 22px;
    background: linear-gradient(180deg, var(--vino) 0%, var(--vino-claro) 100%);
    color: var(--blanco);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 140px;
    height: 140px;
    border-radius: 35px;
    background: var(--beige);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 4px solid rgba(255,255,255,0.6);
    box-shadow: 0 10px 24px rgba(0,0,0,0.25);
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-text h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-align: center;
}

.brand-text p {
    margin: 4px 0 0;
    font-size: 14px;
    opacity: 0.9;
    text-align: center;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
    background: linear-gradient(180deg, rgba(224, 206, 124, 0.12) 0%, rgba(255,255,255,0) 40%);
}

.top-actions {
    display: flex;
    justify-content: flex-end;
}

#new-chat-button {
    background: var(--beige);
    color: var(--vino);
    border: none;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transition: background 0.15s ease, transform 0.1s ease;
}

#new-chat-button:hover {
    background: #d4c36f;
}

#new-chat-button:active {
    transform: translateY(1px);
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 12px;
    background: var(--blanco);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 78%;
    padding: 10px 12px;
    border-radius: 12px;
    line-height: 1.4;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.message.user {
    align-self: flex-end;
    background: var(--vino-claro);
    color: var(--blanco);
    border-bottom-right-radius: 4px;
}

.message.bot {
    align-self: flex-start;
    background: #f3ede0;
    border: 1px solid rgba(81, 5, 5, 0.08);
    color: var(--text);
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
}

/* Estilos específicos para Markdown */
.message.bot p { margin: 0 0 10px 0; }
.message.bot p:last-child { margin-bottom: 0; }
.message.bot ul, .message.bot ol { margin: 5px 0 10px 20px; padding: 0; }
.message.bot li { margin-bottom: 5px; }
.message.bot strong { color: var(--vino); font-weight: 700; }
.message.bot h1, .message.bot h2, .message.bot h3 { 
    margin: 10px 0; 
    color: var(--vino-claro); 
    font-size: 1.1em;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

#message-input {
    flex: 1;
    resize: vertical;
    min-height: 52px;
    max-height: 180px;
    padding: 12px;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--blanco);
    transition: border 0.15s ease, box-shadow 0.15s ease;
}

#message-input:focus {
    outline: none;
    border-color: var(--vino-claro);
    box-shadow: 0 0 0 3px rgba(157, 27, 50, 0.15);
}

#send-button {
    background: var(--vino);
    color: var(--blanco);
    border: none;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    min-width: 90px;
    transition: background 0.15s ease, transform 0.1s ease;
    box-shadow: 0 6px 18px rgba(81, 5, 5, 0.25);
}

#send-button:hover {
    background: var(--vino-claro);
}

#send-button:active {
    transform: translateY(1px);
}

.sidebar-action {
    width: 100%;
    background: var(--beige);
    color: var(--vino);
    border: none;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transition: background 0.15s ease, transform 0.1s ease;
}

.sidebar-action:hover {
    background: #d4c36f;
}

.sidebar-action:active {
    transform: translateY(1px);
}

@media (max-width: 800px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex-direction: row;
        justify-content: center;
    }
    .brand { flex-direction: row; }
    .avatar { width: 96px; height: 96px; border-radius: 20px; }
    .chat-main { height: calc(100vh - 200px); }
    .message { max-width: 100%; }
}