* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Lato', sans-serif;
    background: #f5f5f5;
    color: #212121;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 75px 1fr;
    height: 100vh;
}

/* Header con logos */
.header {
    grid-column: 1 / -1;
    background: #003684;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 50px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-img {
    height: 45px;
    width: auto;
    object-fit: contain;
    transition: all 0.3s ease;
}

/* Solo el primer logo (izquierda) con fondo blanco */
.logo-container:first-child .logo-img {
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.logo-container:first-child .logo-img:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Logo de la derecha sin cambios */
.logo-img:hover {
    opacity: 0.85;
}

/* Sidebar Izquierdo */
.sidebar {
    background: #ffffff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.new-chat-btn {
    width: 100%;
    padding: 14px;
    background: #003684;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.new-chat-btn:hover {
    background: #0023c9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 54, 132, 0.3);
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-item {
    padding: 14px 16px;
    margin-bottom: 8px;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-item:hover {
    background: rgba(0, 54, 132, 0.05);
    border-color: rgba(0, 54, 132, 0.15);
}

.chat-item.active {
    background: #003684;
    color: #ffffff;
    border-color: #003684;
}

.chat-item-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-name.editing {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    outline: none;
    color: inherit;
    font-family: 'Lato', sans-serif;
}

.chat-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-item:hover .chat-actions,
.chat-item.active .chat-actions {
    opacity: 1;
}

.chat-action-btn {
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-action-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.chat-item.active .chat-action-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.chat-item.active .chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Area */
.chat-area {
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    position: relative;
    overflow: hidden;
}

.chat-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 40px 0 180px 0;
    scroll-behavior: smooth;
}

/* CONTENEDOR CENTRADO - IGUAL QUE EL INPUT */
.messages-container {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 0 40px;
    min-height: 100%;
}

/* MENSAJES */
.message {
    margin-bottom: 32px;
    animation: fadeIn 0.5s ease;
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
}

/* Mensaje de bienvenida */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 40px;
    color: #757575;
    animation: fadeIn 0.8s ease;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.5;
}

.welcome-title {
    font-size: 28px;
    font-weight: 700;
    color: #616161;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.welcome-subtitle {
    font-size: 16px;
    font-weight: 400;
    color: #878787;
    max-width: 500px;
    line-height: 1.6;
}

.message.bot {
    justify-items: start;
}

.message.user {
    justify-items: end;
}

.message-bubble {
    max-width: 85%;
    padding: 18px 22px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.message.bot .message-bubble {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #003684;
}

.message.user .message-bubble {
    background: #003684;
    color: #ffffff;
}

.message-header {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 10px;
    opacity: 0.75;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.message.bot .message-header {
    color: #003684;
}

.message.user .message-header {
    color: rgba(255, 255, 255, 0.8);
}

.message-content {
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.message-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin-bottom: 8px;
}

.message-content strong {
    font-weight: 700;
}

.typing-indicator {
    background: #ffffff;
    padding: 18px 22px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
    display: inline-block;
}

.typing-dots {
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #003684;
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Input Area - CENTRADO CON LA CONVERSACIÓN */
.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, #f5f5f5 85%, transparent);
    padding: 30px 0;
    z-index: 10;
}

.input-wrapper {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 0 40px;
}

.chat-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: #ffffff;
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.chat-form:focus-within {
    border-color: #003684;
    box-shadow: 0 6px 24px rgba(0, 54, 132, 0.15);
}

.input-field {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Lato', sans-serif;
    font-size: 15px;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    line-height: 1.5;
    color: #212121;
    background: transparent;
}

.input-field::placeholder {
    color: #9e9e9e;
}

.send-btn {
    background: #003684;
    color: #ffffff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: #0023c9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 54, 132, 0.3);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-10px);
    }
}

/* Scrollbar personalizado */
.chats-list::-webkit-scrollbar,
.chat-wrapper::-webkit-scrollbar {
    width: 8px;
}

.chats-list::-webkit-scrollbar-track,
.chat-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.chats-list::-webkit-scrollbar-thumb,
.chat-wrapper::-webkit-scrollbar-thumb {
    background: #c5c5c5;
    border-radius: 10px;
}

.chats-list::-webkit-scrollbar-thumb:hover,
.chat-wrapper::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .header {
        padding: 0 20px;
    }

    .logo-img {
        height: 35px;
    }

    .messages-container,
    .input-wrapper {
        padding: 0 20px;
    }

    .welcome-message {
        padding: 40px 20px;
    }

    .welcome-title {
        font-size: 22px;
    }

    .welcome-subtitle {
        font-size: 14px;
    }
}