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

:root {
    --primary-color: #4a90e2;
    --secondary-color: #f39c12;
    --danger-color: #e74c3c;
    --success-color: #27ae60;
    --light-bg: #f5f7fa;
    --dark-text: #2c3e50;
    --border-color: #ecf0f1;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--light-bg);
    color: var(--dark-text);
    line-height: 1.6;
}

/* Autenticação */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 20px;
}

.auth-container h2 {
    color: white;
    margin-bottom: 30px;
    font-size: 28px;
}

.auth-container form {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-text);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.auth-container p {
    margin-top: 20px;
    text-align: center;
    color: #666;
}

.auth-container a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-container a:hover {
    text-decoration: underline;
}

.message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 4px;
    text-align: center;
    display: none;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* Botões */
.btn-primary {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-primary:hover {
    background-color: #3a7bc8;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.btn-icon:hover {
    background-color: rgba(74, 144, 226, 0.1);
}

/* Chat Container */
.chat-container {
    display: flex;
    height: 100vh;
    background-color: white;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 18px;
    margin: 0;
}

.sidebar-header .btn-icon {
    color: white;
    padding: 4px 8px;
}

.sidebar-header .btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.conversation-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.conversation-item {
    padding: 15px 20px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background-color 0.3s, border-color 0.3s;
}

.conversation-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.conversation-item.active {
    background-color: rgba(74, 144, 226, 0.2);
    border-left-color: var(--primary-color);
}

.conversation-item-title {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item-date {
    font-size: 12px;
    opacity: 0.7;
}

.user-info {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info span {
    font-size: 14px;
}

.logout-btn {
    color: var(--danger-color);
}

.logout-btn:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

/* Chat Main */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 20px;
}

.chat-header .btn-icon {
    margin-left: 10px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-wrapper {
    display: flex;
    margin-bottom: 10px;
}

.message-wrapper.user {
    justify-content: flex-end;
}

.message-wrapper.ia {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 8px;
    word-wrap: break-word;
}

.message-wrapper.user .message-bubble {
    background-color: var(--primary-color);
    color: white;
}

.message-wrapper.ia .message-bubble {
    background-color: var(--light-bg);
    color: var(--dark-text);
    border: 1px solid var(--border-color);
}

.message-bubble p {
    margin: 0;
}

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

.message-bubble pre {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-bubble pre code {
    background: none;
    padding: 0;
}

.message-meta {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 4px;
}

.typing-indicator {
    font-size: 14px;
    color: #999;
    font-style: italic;
    padding: 10px 0;
}

.typing-indicator::after {
    content: '';
    animation: typing 1.5s infinite;
}

@keyframes typing {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* Chat Input Area */
.chat-input-area {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: white;
}

#messageInput {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 10px;
    transition: border-color 0.3s;
}

#messageInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

#sendMessageBtn {
    width: 100%;
}

/* Responsivo */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .conversation-list {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .conversation-item {
        flex-shrink: 0;
        min-width: 200px;
    }

    .message-bubble {
        max-width: 90%;
    }

    .auth-container form {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .message-bubble {
        max-width: 100%;
    }

    .chat-header h3 {
        font-size: 16px;
    }

    .sidebar-header h3 {
        font-size: 14px;
    }
}

/* Scrollbar Customizado */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}
