/* ====================================
   Chat Sidebar Styles
   ==================================== */

#chat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background: #fff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

#chat-sidebar.active {
    transform: translateX(0);
}

/* Ocultar el sidebar del menú cuando el chat está activo */
body.chat-sidebar-open .sidenav-menu {
    transform: translateX(-100%);
}

/* Header del Chat */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.chat-header-text h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-header-text p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.chat-header-actions button {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Área de Mensajes */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Mensaje Individual */
.chat-message {
    display: flex;
    gap: 10px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mensaje del Usuario */
.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Mensaje del Bot */
.bot-message .message-content {
    background: white;
    color: #333;
    margin-right: auto;
}

.bot-message .message-avatar {
    background: #e9ecef;
    color: #6c757d;
}

/* Avatar del Mensaje */
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

/* Contenido del Mensaje */
.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
}

.message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.message-time {
    display: block;
    font-size: 11px;
    margin-top: 5px;
    opacity: 0.7;
}

/* Footer del Chat (Input) */
.chat-footer {
    padding: 15px;
    background: white;
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.chat-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 25px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#chat-send-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 20px;
}

#chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#chat-send-btn:active {
    transform: scale(0.95);
}

/* Botón del Chat en Topbar */
.chat-toggle-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 20px;
    position: relative;
}

.chat-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

/* Badge de notificación (opcional) */
.chat-toggle-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Scrollbar personalizado */
.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Animación de escritura (typing indicator) */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Estado vacío */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.chat-empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.chat-empty-state h4 {
    margin-bottom: 10px;
    font-size: 18px;
    font-weight: 600;
}

.chat-empty-state p {
    font-size: 14px;
    opacity: 0.8;
}

/* Responsive */
@media (max-width: 768px) {
    #chat-sidebar {
        width: 100%;
    }

    .message-content {
        max-width: 85%;
    }
}

/* Dark mode support (opcional) */
@media (prefers-color-scheme: dark) {
    #chat-sidebar {
        background: #1a1d23;
    }

    .chat-body {
        background: #0f1115;
    }

    .bot-message .message-content {
        background: #2a2d35;
        color: #e0e0e0;
    }

    .chat-footer {
        background: #1a1d23;
        border-top-color: #2a2d35;
    }

    #chat-input {
        background: #2a2d35;
        border-color: #2a2d35;
        color: #e0e0e0;
    }

    #chat-input:focus {
        border-color: #667eea;
    }
}

/* Transición suave para el sidebar del menú */
.sidenav-menu {
    transition: transform 0.3s ease-in-out;
}

.sidenav-menu.chat-active {
    transform: translateX(-100%);
}
