:root {
    --bg-color: #131314;
    --sidebar-bg: #1e1f20;
    --input-bg: #28292a;
    --text-primary: #e3e3e3;
    --text-secondary: #c4c7c5;
    --accent-color: #a8c7fa;
    --user-msg-bg: #28292a;
    --border-color: #444746;
}

* {
    box-sizing: border-box;
    margin: 0; padding: 0;
    font-family: 'Google Sans', 'Roboto', Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    height: 100vh; height: 100dvh;
    overflow: hidden;
}

/* --- TELA DE LOGIN (CAMADA 2000) --- */
.login-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: var(--bg-color);
    z-index: 2000; /* Bloqueia o Dashboard */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

/* --- MODAIS (CAMADA 2005 - ACIMA DO LOGIN) --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.85); /* Fundo bem escuro */
    backdrop-filter: blur(5px);
    z-index: 2005; /* ACIMA DO LOGIN! */
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-box {
    width: 90%; max-width: 400px; padding: 40px;
    background-color: var(--sidebar-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative;
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px;
}
.modal-header h3 { font-weight: 500; color: var(--accent-color); }
.close-modal { background: none; border: none; color: var(--text-secondary); font-size: 1.5rem; cursor: pointer; }

.login-logo { margin-bottom: 20px; }
.login-logo span { font-size: 3rem; color: var(--accent-color); display: block; margin-bottom: 10px; }
.login-logo h2 { font-weight: 500; font-size: 1.5rem; }
.login-box p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 30px; }

.input-group {
    background-color: var(--input-bg);
    border-radius: 8px; margin-bottom: 15px;
    display: flex; align-items: center; padding: 0 10px;
    border: 1px solid transparent; transition: border 0.3s;
}
.input-group:focus-within { border-color: var(--accent-color); }
.input-group span { color: var(--text-secondary); }
.input-group input { background: none; border: none; color: white; width: 100%; padding: 12px; outline: none; font-size: 1rem; }

.login-btn {
    width: 100%; padding: 12px;
    background-color: var(--accent-color);
    color: #000; font-weight: bold;
    border: none; border-radius: 8px;
    cursor: pointer; font-size: 1rem;
    margin-top: 10px; transition: 0.2s;
}
.login-btn:hover { background-color: #8ab4f8; }

.auth-options { display: flex; justify-content: space-between; margin-top: 20px; font-size: 0.85rem; }
.auth-options a { color: var(--text-secondary); text-decoration: none; transition: 0.2s; }
.auth-options a:hover { color: var(--accent-color); }
.login-footer { margin-top: 30px; font-size: 0.75rem; opacity: 0.5; margin-bottom: 0 !important; }

/* --- SIDEBAR & MAIN CONTENT (CAMADA PADRÃO DA VERSÃO V0) --- */
.sidebar {
    width: 260px; background-color: var(--sidebar-bg);
    display: flex; flex-direction: column; padding: 10px;
    border-right: 1px solid rgba(255,255,255,0.05);
    transition: transform 0.3s ease, width 0.3s ease;
    flex-shrink: 0; z-index: 100;
}
.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .text, .sidebar.collapsed .sidebar-section h3, .sidebar.collapsed .new-chat-btn .text, .sidebar.collapsed .location-info { display: none; }

.sidebar-header { height: 50px; display: flex; align-items: center; padding-left: 10px; }
.icon-btn { background: none; border: none; color: var(--text-secondary); padding: 10px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.mobile-menu-btn { display: none; margin-right: 10px; }
.new-chat-container { margin: 20px 0; }
.new-chat-btn { background-color: #28292a; color: var(--text-secondary); border: 1px solid rgba(255,255,255,0.1); border-radius: 20px; padding: 10px 15px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: 0.2s; width: 100%; white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .new-chat-btn { width: 40px; padding: 10px; justify-content: center; border-radius: 50%; }
.sidebar-section { flex-grow: 1; margin-top: 20px; overflow-y: auto; }
.section-title { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 10px; padding-left: 15px; text-transform: uppercase; }
.nav-list { list-style: none; }
.nav-item { display: flex; align-items: center; gap: 15px; padding: 12px 15px; border-radius: 25px; color: var(--text-primary); cursor: pointer; transition: background 0.2s; font-size: 0.95rem; background: none; border: none; width: 100%; text-align: left; }
.nav-item:hover { background-color: rgba(255,255,255,0.08); }
.nav-item.active { background-color: #004a77; color: #c2e7ff; }
.sidebar-footer { margin-top: auto; font-size: 0.8rem; color: var(--text-secondary); padding-bottom: 10px; }
.location-info { font-size: 0.7rem; padding: 5px 15px; color: #666; }

.main-content { flex-grow: 1; display: flex; flex-direction: column; position: relative; max-width: 100%; width: 100%; }
.top-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; height: 60px; background-color: var(--bg-color); position: sticky; top: 0; z-index: 10; }
.logo-area { display: flex; align-items: center; }
.app-name { font-size: 1.1rem; color: var(--text-secondary); font-weight: 500; }
.user-area { display: flex; align-items: center; gap: 10px; }
.badge-pro { background-color: #2b2c2e; color: var(--text-secondary); font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; border: 1px solid #444; }
.avatar-placeholder { width: 32px; height: 32px; background-color: #7c4dff; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: bold; }

.chat-history { flex-grow: 1; overflow-y: auto; padding: 20px 15px 120px 15px; display: flex; flex-direction: column; align-items: center; width: 100%; }
.welcome-screen { margin-top: 15vh; text-align: center; color: #444746; padding: 0 20px; }
.welcome-screen h1 { font-weight: 500; font-size: 2rem; margin-top: 15px; line-height: 1.2; }
.message-wrapper { width: 100%; max-width: 800px; margin-bottom: 25px; display: flex; gap: 12px; }
.message-wrapper.user { justify-content: flex-end; }
.avatar-icon { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.75rem; }
.avatar-icon.ai { background: linear-gradient(135deg, #4285F4, #DB4437); color: white; }
.avatar-icon.user { background-color: #444; color: #fff; }
.message-content { color: var(--text-primary); line-height: 1.5; font-size: 0.95rem; max-width: 90%; word-wrap: break-word; }
.message-wrapper.user .message-content { background-color: var(--user-msg-bg); padding: 10px 15px; border-radius: 18px 18px 4px 18px; }
.message-content pre { background-color: #1e1f20; padding: 12px; border-radius: 8px; overflow-x: auto; font-family: 'Roboto Mono', monospace; font-size: 0.85rem; white-space: pre-wrap; margin-top: 5px; border: 1px solid #333; }

.input-container { position: absolute; bottom: 0; left: 0; width: 100%; padding: 15px 15px 20px 15px; background: linear-gradient(to top, var(--bg-color) 85%, transparent); display: flex; flex-direction: column; align-items: center; }
.prompt-bar { width: 100%; max-width: 800px; background-color: var(--input-bg); border-radius: 28px; padding: 8px 12px; display: flex; align-items: flex-end; gap: 8px; border: 1px solid transparent; }
.prompt-bar:focus-within { border-color: rgba(255,255,255,0.2); }
.prompt-bar textarea { background: transparent; border: none; color: var(--text-primary); font-size: 1rem; flex-grow: 1; outline: none; resize: none; max-height: 120px; padding: 12px 0; line-height: 1.4; }
.icon-btn-bar { background: none; border: none; color: var(--text-secondary); padding: 8px; cursor: pointer; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.send-btn { color: var(--text-primary); }
.icon-btn-bar.recording { background-color: rgba(220, 53, 69, 0.2); color: #ff6b6b; animation: pulse 1.5s infinite; border: 1px solid #ff6b6b; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(255, 107, 107, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); } }

.file-list-container { width: 100%; max-width: 800px; background-color: #1e1f20; border-radius: 12px 12px 0 0; padding: 10px 15px; margin-bottom: -15px; display: flex; gap: 10px; overflow-x: auto; border: 1px solid #333; border-bottom: none; z-index: 1; }
.file-chip { background-color: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; padding: 6px 10px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; max-width: 200px; }
.file-chip .file-name { font-size: 0.8rem; color: var(--accent-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .remove-btn { background: none; border: none; color: #888; cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; }
.file-chip .remove-btn:hover { color: #ff6b6b; }
.typing-indicator span { display: inline-block; width: 6px; height: 6px; background-color: #888; border-radius: 50%; animation: typing 1.4s infinite ease-in-out both; margin: 0 2px; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* OVERLAY MOBILE */
.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 99; opacity: 0; visibility: hidden; transition: 0.3s; backdrop-filter: blur(2px); }
.sidebar-overlay.active { opacity: 1; visibility: visible; }
@media (max-width: 768px) {
    .sidebar { position: absolute; top: 0; left: 0; height: 100%; width: 280px; transform: translateX(-100%); box-shadow: 2px 0 10px rgba(0,0,0,0.5); }
    .sidebar.mobile-open { transform: translateX(0); }
    #desktop-sidebar-toggle { display: none; }
    .mobile-menu-btn { display: block; }
    .welcome-screen h1 { font-size: 1.8rem; }
    .chat-history { padding-left: 10px; padding-right: 10px; }
    .message-content { max-width: 95%; font-size: 0.9rem; }
}