* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background: #f0f2f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* HEADER */
.header {
    background: #16a34a;
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-logo {
    background: white;
    border-radius: 8px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
}

.header-logo img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.header-info h1 {
    font-size: 20px;
    font-weight: 600;
}

.header-info p {
    font-size: 13px;
    opacity: 0.85;
}

/* CHAT */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.bot {
    align-self: flex-start;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.user .avatar {
    background: #16a34a;
}

.bot .avatar {
    background: #dcfce7;
}

.bubble {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 100%;
}

.user .bubble {
    background: #16a34a;
    color: white;
    border-bottom-right-radius: 4px;
}

.bot .bubble {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.resumen {
    font-size: 14px;
    line-height: 1.6;
}

/* TABLA */
.tabla-container {
    margin-top: 12px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th {
    background: #16a34a;
    color: white;
    padding: 8px 10px;
    text-align: left;
}

td {
    padding: 7px 10px;
    border-bottom: 1px solid #e5e7eb;
}

tr:hover td {
    background: #f9fafb;
}

/* SQL */
.sql-box {
    margin-top: 10px;
    background: #1f2937;
    color: #10b981;
    padding: 10px;
    border-radius: 8px;
    font-size: 11px;
    font-family: monospace;
    white-space: pre-wrap;
    display: none;
}

.sql-label {
    font-size: 11px;
    color: #6b7280;
    margin-top: 8px;
    cursor: pointer;
}

/* INPUT */
.input-area {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
}

.input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.input-area input:focus {
    border-color: #16a34a;
}

.input-area button {
    background: #16a34a;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    cursor: pointer;
}

.input-area button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* LOADING */
.loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 13px;
}

.dot {
    width: 8px;
    height: 8px;
    background: #16a34a;
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* SUGERENCIAS */
.sugerencias {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.sugerencia {
    background: #dcfce7;
    color: #16a34a;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid #bbf7d0;
}

.sugerencia:hover {
    background: #bbf7d0;
}

.header {
    justify-content: space-between;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.header-user span {
    font-size: 14px;
    font-weight: 500;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

.export-botones {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-export {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: white;
}

.btn-excel {
    background: #16a34a;
}

.btn-excel:hover {
    background: #15803d;
}

.btn-pdf {
    background: #dc2626;
}

.btn-pdf:hover {
    background: #b91c1c;
}

.paginacion {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    font-size: 13px;
    color: #4b5563;
}

.paginacion button {
    padding: 4px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.paginacion button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.paginacion-info {
    text-align: center;
    font-size: 12px;
    color: #6b7280;
    padding: 6px;
}

.sugerencias {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.btn-sugerencia {
    text-align: left;
    padding: 8px 12px;
    background: #f0fdf4;
    border: 1px solid #16a34a;
    color: #15803d;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.btn-sugerencia:hover {
    background: #dcfce7;
}

/* ===== Layout: sidebar + area principal ===== */
.layout {
    display: flex;
    height: calc(100vh - 80px); /* ajustar segun alto del header */
    overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: #f7f8fa;
    border-right: 1px solid #e3e6ea;
    display: flex;
    flex-direction: column;
    padding: 12px;
    box-sizing: border-box;
}

.btn-nuevo-chat {
    width: 100%;
    padding: 10px 12px;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 14px;
    transition: background 0.15s;
}
.btn-nuevo-chat:hover {
    background: #15803d;
}

.chats-titulo {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin: 4px 4px 8px;
    font-weight: 600;
}

.lista-chats {
    flex: 1;
    overflow-y: auto;
}

.sin-chats {
    color: #9ca3af;
    font-size: 13px;
    padding: 10px 4px;
    text-align: center;
}

/* Cada item de chat */
.chat-item {
    position: relative;
    padding: 10px 32px 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.12s;
}
.chat-item:hover {
    background: #eceff3;
}
.chat-item-activo {
    background: #e3f2e8;
}
.chat-item-activo:hover {
    background: #d7ebdf;
}

.chat-item-titulo {
    font-size: 13.5px;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.chat-item-fecha {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

/* Boton archivar (aparece al hover) */
.chat-item-borrar {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.12s;
    padding: 4px;
    border-radius: 4px;
}
.chat-item:hover .chat-item-borrar {
    opacity: 0.6;
}
.chat-item-borrar:hover {
    opacity: 1 !important;
    background: #fde2e2;
}

/* ===== AREA principal ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* permite que el contenido no desborde */
}

/* El chat-container y input-area ya tienen estilos en style.css;
   aca solo aseguramos que ocupen el area principal correctamente */
.main .chat-container {
    flex: 1;
    overflow-y: auto;
}

/* ===== Responsive: en pantallas chicas, sidebar mas angosto ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
        min-width: 200px;
    }
}