/* ===== TEMA DARK ELEGANTE ===== */
:root {
    --primary-bg: #0f0f1e;
    --secondary-bg: #1a1a2e;
    --tertiary-bg: #16213e;
    --border-color: #2a2a3e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-color: #00d4ff;
    --accent-light: #00e5ff;
    --success-color: #4ade80;
    --error-color: #ff4d4d;
    --user-bubble: #00d4ff;
    --assistant-bubble: #1a1a2e;
}

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

html, body {
    height: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    overflow: hidden;
}

body {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* ===== CONTAINER PRINCIPAL ===== */
.container {
    display: flex;
    height: 100%;
    width: 100%;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    background: var(--secondary-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

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

.sidebar-header h1 {
    font-size: 1.2rem;
    color: var(--accent-color);
}

.sidebar-header button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    transition: color 0.3s;
}

.sidebar-header button:hover {
    color: var(--accent-color);
}

/* ===== MODOS DE ESTUDO ===== */
.study-modes {
    padding: 15px 10px;
    border-bottom: 1px solid var(--border-color);
}

.study-modes h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 10px;
    padding: 0 10px;
    letter-spacing: 0.5px;
}

.mode-button {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-button:hover {
    background: var(--tertiary-bg);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.mode-button.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--primary-bg);
    font-weight: 600;
}

.mode-icon {
    font-size: 1.2rem;
}

/* ===== CONVERSAS ===== */
.conversations-section {
    flex: 1;
    padding: 15px 10px;
    overflow-y: auto;
}

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

.conversations-header h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-new-conv {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 1.3rem;
    padding: 2px;
    transition: transform 0.3s;
}

.btn-new-conv:hover {
    transform: scale(1.2);
}

.conversation-item {
    padding: 12px 10px;
    margin-bottom: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-item:hover {
    background: var(--tertiary-bg);
    border-color: var(--accent-color);
}

.conversation-item.active {
    background: var(--accent-color);
    color: var(--primary-bg);
    font-weight: 600;
}

.conversation-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-delete-conv {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 5px;
    transition: color 0.3s;
    display: none;
}

.conversation-item:hover .btn-delete-conv {
    display: block;
}

.btn-delete-conv:hover {
    color: var(--error-color);
}

/* ===== BOTÃO LOGOUT ===== */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

.btn-logout {
    width: 100%;
    padding: 12px;
    background: var(--error-color);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: #ff6666;
}

/* ===== ÁREA DE CHAT ===== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--primary-bg);
}

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

.chat-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.api-status.connected {
    color: var(--success-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== MENSAGENS ===== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 20px;
    max-width: 300px;
}

.suggestions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 400px;
}

.suggestion-btn {
    padding: 12px 15px;
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    text-align: left;
}

.suggestion-btn:hover {
    background: var(--accent-color);
    color: var(--primary-bg);
    border-color: var(--accent-color);
}

/* ===== MENSAGENS DO CHAT ===== */
.message {
    display: flex;
    margin-bottom: 10px;
    animation: slideIn 0.3s ease;
}

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

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

.message.assistant {
    justify-content: flex-start;
}

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

.message.user .message-bubble {
    background: var(--user-bubble);
    color: var(--primary-bg);
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: var(--assistant-bubble);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* ===== MARKDOWN NO CHAT ===== */
.message-bubble code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.message-bubble pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85em;
}

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

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

.message-bubble em {
    font-style: italic;
}

.message-bubble ul, .message-bubble ol {
    margin-left: 20px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.message-bubble li {
    margin-bottom: 5px;
}

.message-bubble table {
    border-collapse: collapse;
    margin: 10px 0;
    width: 100%;
    font-size: 0.9em;
}

.message-bubble th, .message-bubble td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
}

.message-bubble th {
    background: rgba(0, 212, 255, 0.1);
    font-weight: 600;
}

/* ===== INDICADOR DE DIGITAÇÃO ===== */
.typing-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-color);
    animation: typing 1.4s infinite;
}

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

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

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

/* ===== INPUT DE MENSAGEM ===== */
.message-form {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--secondary-bg);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 12px 15px;
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: border-color 0.3s;
    -webkit-appearance: none;
}

.message-input:focus {
    border-color: var(--accent-color);
}

.message-input::placeholder {
    color: var(--text-secondary);
}

.btn-send {
    padding: 12px 20px;
    background: var(--accent-color);
    border: none;
    border-radius: 8px;
    color: var(--primary-bg);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    height: 44px;
}

.btn-send:hover:not(:disabled) {
    background: var(--accent-light);
}

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

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 60px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .sidebar-header {
        padding: 10px 15px;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        min-width: 60px;
    }
    
    .study-modes {
        display: flex;
        gap: 10px;
        padding: 10px;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        overflow-x: auto;
        flex: 1;
    }
    
    .study-modes h3 {
        display: none;
    }
    
    .mode-button {
        margin-bottom: 0;
        white-space: nowrap;
        flex-shrink: 0;
        min-width: 120px;
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .conversations-section {
        display: none;
    }
    
    .sidebar-footer {
        display: none;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .messages-container {
        padding: 15px;
    }
    
    .message-form {
        padding: 15px;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

