:root {
    --primary-color: #7e57c2;
    --primary-dark: #673ab7;
    --secondary-color: #ff5722;
    --background-color: #f5f7fb;
    --card-background: #ffffff;
    --text-color: #333333;
    --text-light: #6c757d;
    --border-color: #e0e0e0;
    --user-msg-bg: #7e57c2;
    --bot-msg-bg: #f5f5f5;
    --online-status: #4caf50;
    --away-status: #ff9800;
    --sidebar-width: 280px;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --error-color: #f44336;
    --success-color: #4caf50;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(to bottom, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo i {
    font-size: 28px;
}

.logo h1 {
    font-size: 22px;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    position: relative;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 20px;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.user-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--online-status);
}

.logout-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu {
    margin: 20px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu-item.active {
    background: rgba(255, 255, 255, 0.15);
}

.menu-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.guest-warning {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-top: auto;
    font-size: 13px;
}

.guest-warning p {
    margin-bottom: 12px;
    line-height: 1.5;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-btn {
    padding: 10px;
    border-radius: var(--border-radius);
    border: none;
    background: white;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
}

.auth-btn:hover {
    background: #f0f0f0;
}

.auth-btn.register {
    background: var(--secondary-color);
    color: white;
}

.auth-btn.register:hover {
    background: #e64a19;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.header {
    padding: 15px 25px;
    background: var(--card-background);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 15px;
}

.header-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-light);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    transition: all 0.3s;
}

.header-btn:hover {
    background: var(--background-color);
    color: var(--primary-color);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 75%;
    padding: 15px;
    border-radius: 18px;
    animation: fadeIn 0.3s ease;
    position: relative;
    line-height: 1.5;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    background-color: var(--user-msg-bg);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.bot-message {
    background-color: var(--bot-msg-bg);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message-info {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 8px;
    text-align: right;
}

.bot-message .message-info {
    text-align: left;
}

/* Estilos para texto formateado */
.message strong {
    font-weight: 600;
    color: inherit;
}

.bot-message strong {
    color: var(--primary-color);
}

.user-message strong {
    color: #ffffff;
}

.message em {
    font-style: italic;
    opacity: 0.9;
}

.message code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.bot-message code {
    background: rgba(126, 87, 194, 0.1);
    color: var(--primary-color);
}

.user-message code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.message p {
    margin: 8px 0;
    line-height: 1.5;
}

.message p:first-child {
    margin-top: 0;
}

.message p:last-child {
    margin-bottom: 0;
}

.message ul, .message ol {
    margin: 10px 0;
    padding-left: 20px;
}

.message li {
    margin: 5px 0;
    line-height: 1.4;
}

.message h3, .message h4, .message h5 {
    margin: 15px 0 10px 0;
    font-weight: 600;
}

.bot-message h3, .bot-message h4, .bot-message h5 {
    color: var(--primary-color);
}

.user-message h3, .user-message h4, .user-message h5 {
    color: #ffffff;
}

.message h3 {
    font-size: 1.2em;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
}

.message h4 {
    font-size: 1.1em;
}

.message h5 {
    font-size: 1em;
}

/* Estilos para gráficas */
.chart-container {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

.response-chart {
    width: 100% !important;
    height: 100% !important;
}

.chart-caption {
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-light);
    font-style: italic;
}

.chart-error {
    text-align: center;
    padding: 20px;
    color: var(--error-color);
    background: #f8d7da;
    border-radius: 5px;
}

/* Estilos para sugerencias */
.suggestions-container {
    margin-top: 15px;
    padding: 15px;
    background: rgba(126, 87, 194, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(126, 87, 194, 0.2);
}

.suggestions-title {
    font-size: 14px;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-weight: 600;
}

.suggestion-btn {
    display: block;
    width: 100%;
    padding: 10px 15px;
    margin: 5px 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    transition: all 0.3s;
    color: var(--text-color);
}

.suggestion-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateX(5px);
}

/* Indicador de typing */
.typing-indicator {
    display: inline-flex;
    background-color: var(--bot-msg-bg);
    padding: 15px;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    align-self: flex-start;
}

.typing-indicator span {
    height: 10px;
    width: 10px;
    background-color: var(--text-light);
    border-radius: 50%;
    display: inline-block;
    margin: 0 3px;
    animation: typing 1.5s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.input-area {
    display: flex;
    padding: 15px;
    border-radius: var(--border-radius);
    background-color: var(--card-background);
    box-shadow: var(--shadow);
    gap: 12px;
}

#user-input {
    flex: 1;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    resize: none;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
    max-height: 150px;
}

#user-input:focus {
    border-color: var(--primary-color);
}

#send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-btn:hover {
    background-color: var(--primary-dark);
    transform: scale(1.05);
}

#send-btn:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

/* Modal de autenticación */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: var(--card-background);
    margin: 10% auto;
    padding: 30px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 450px;
    position: relative;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s;
}

.modal-content.large {
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    color: var(--text-light);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    position: absolute;
    right: 15px;
    top: 15px;
}

.close:hover {
    color: var(--text-color);
}

.modal-title {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--primary-color);
    text-align: center;
}

#auth-form input {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

#auth-form input:focus {
    border-color: var(--primary-color);
}

#auth-form button {
    width: 100%;
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    margin-top: 15px;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.3s;
}

#auth-form button:hover {
    background-color: var(--primary-dark);
}

.auth-message {
    padding: 10px;
    border-radius: var(--border-radius);
    margin: 10px 0;
    text-align: center;
    display: none;
}

.auth-message.error {
    background-color: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    display: block;
}

.auth-message.success {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
    display: block;
}

#auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 600;
}

#auth-switch:hover {
    text-decoration: underline;
}

.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.conversation-item {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s;
}

.conversation-item:hover {
    background-color: var(--background-color);
    border-color: var(--primary-color);
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.conversation-date {
    font-size: 12px;
    color: var(--text-light);
}

.conversation-preview {
    font-size: 14px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive */
@media (max-width: 900px) {
    body {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        padding: 15px;
    }
    
    .message {
        max-width: 85%;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 12px 15px;
    }
    
    .chat-container {
        padding: 15px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-area {
        padding: 12px;
    }
    
    .modal-content {
        margin: 5% auto;
        padding: 20px;
    }
}