/* EUGENIA - CSS NOVO ADAPTADO AO HTML ATUAL */
:root {
    --verde-principal: #27ae60;
    --verde-escuro: #229954;
    --texto-principal: #2c3e50;
    --cinza-fundo: #f5f7fa;
    --cinza-borda: #e0e0e0;
    --sidebar-bg: var(--verde-escuro);
    --sidebar-text: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, 0.15);
    --primary-color: var(--verde-principal);
    --primary-color-hover: var(--verde-escuro);
    --bg-light: var(--cinza-fundo);
    --card-bg: #ffffff;
    --text-main: var(--texto-principal);
    --text-muted: #7f8c8d;
    --border-color: var(--cinza-borda);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
}

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

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
}

#app-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/*{
    display: flex;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}*/


/* SIDEBAR */
#sidebar {
    width: 260px;
    min-width: 260px;
    height: 100vh;
    background: linear-gradient(135deg, var(--verde-principal) 0%, var(--verde-escuro) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, min-width 0.3s ease;
    z-index: 10;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow: hidden;
    flex-shrink: 0;
}


#sidebar.collapsed { width: 0; min-width: 0; }

#sidebar-top {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-logo {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    padding: 2px;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

.sidebar-icon-btn {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    border-radius: 8px;
}
.sidebar-icon-btn:hover { transform: scale(1.1); background: rgba(255,255,255,0.15); }

#btn-new-chat {
    margin: 16px;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--sidebar-text);
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
#btn-new-chat:hover { background-color: rgba(255, 255, 255, 0.25); transform: translateY(-1px); }
#btn-new-chat:disabled { opacity: 0.45; cursor: default; transform: none; }

.sidebar-section-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    margin: 0 16px 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

#conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
#conversations-list::-webkit-scrollbar { width: 4px; }
#conversations-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.35); border-radius: 4px; }

.conv-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #ffffff;
    transition: background 0.2s;
    font-weight: 500;
}
.conv-item:hover, .conv-item.active { background-color: var(--sidebar-hover); }
.conv-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.conv-date { font-size: 11px; color: rgba(255,255,255,0.75); flex-shrink: 0; }
.conv-delete { display: none; background: transparent; border: none; color: #fff; cursor: pointer; }
.conv-item:hover .conv-delete { display: block; }
.conv-empty { color: rgba(255,255,255,0.85); font-size: 13px; line-height: 1.6; text-align: center; padding: 25px 8px; }

#sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}
#user-badge-sidebar { display: none; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; color: #fff; }
#user-badge-sidebar.show { display: flex; }
.user-avatar {
    width: 34px; height: 34px; background-color: #ffffff; color: var(--verde-principal);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.user-info { overflow: hidden; }
.user-name { color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,0.75); font-size: 12px; }

/* MAIN */
#main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-light);
    position: relative;
    height: 100vh;
    overflow: hidden;
    min-width: 0;
    padding-bottom: 100px;
}

#topbar {
    height: 64px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    flex-shrink: 0;
}
.topbar-btn {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.topbar-btn:hover { background: var(--card-bg); border-color: var(--primary-color); color: var(--primary-color); }
#current-conv-title { flex: 1; margin-left: 10px; font-size: 16px; font-weight: 700; color: var(--text-main); }

#chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px 145px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#welcome-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
#welcome-screen .welcome-logo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin-bottom: 16px; border: 3px solid var(--cinza-borda); padding: 2px; }
#welcome-screen h1 { font-size: 28px; font-weight: 700; color: var(--text-main); margin-bottom: 10px; }
#welcome-screen p { font-size: 15px; color: var(--text-main); max-width: 680px; line-height: 1.6; }

/* MENSAGENS */
.msg-row {
    width: 100%;
    max-width: 850px;
    display: flex;
    gap: 14px;
    margin-bottom: 8px;
}

.msg-row.user { justify-content: flex-end; }
.msg-row.ai { justify-content: flex-start; }

.msg-row.ai > div:last-child {
    width: 100%;
    max-width: 850px;
}

.ai-response-wrap {
    width: 100%;
    max-width: 850px;
}

.msg-bubble {
    max-width: 100%;
    background: var(--card-bg);
    padding: 18px 22px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid var(--border-color);
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-main);
}

.msg-row.ai .msg-bubble {
    width: 100%;
    border-left: 4px solid var(--verde-principal);
}

.msg-row.user .msg-bubble {
    width: auto;
    max-width: 70%;
    background: var(--verde-principal);
    color: #fff;
    border-color: var(--verde-principal);
    padding: 10px 16px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.msg-bubble p {
    margin: 0 0 14px;
}

.msg-bubble p:last-child {
    margin-bottom: 0;
}

.msg-meta {
    width: 100%;
    max-width: 850px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.msg-meta.user { text-align: right; }
.msg-meta.ai { text-align: left; padding-left: 54px; }
.msg-sender { font-weight: 700; font-size: 15px; margin-bottom: 8px; color: var(--text-main); }
.msg-sender.eugenia { color: var(--verde-principal); }
.ai-avatar {
    width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--verde-principal);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
    border: 2px solid var(--cinza-borda); flex-shrink: 0;
}
.msg-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.msg-action-btn {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    cursor: pointer;
    font-size: 13px;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
    transition: all .2s;
}
.msg-action-btn:hover { color: var(--primary-color); border-color: var(--primary-color); background: rgba(39,174,96,.06); }
.route-badge { background: rgba(39,174,96,.12); color: var(--verde-escuro); border-radius: 12px; padding: 2px 8px; font-size: 11px; }

.typing-dots { display: flex; gap: 4px; padding: 4px 0; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: tdot 1.3s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tdot { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

/* PAINEL LATERAL DE FONTES */
#sources-panel {
    position: fixed;
    top: 64px;
    right: -360px;
    width: 360px;
    height: calc(100vh - 64px - 100px);
    background: #fff;
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 14px rgba(0,0,0,.08);
    z-index: 80;
    transition: right .25s ease;
    display: flex;
    flex-direction: column;
}

#sources-panel.open { right: 0; }

#sources-panel-header {
    height: 56px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#sources-panel-header strong {
    font-size: 16px;
    color: var(--text-main);
}

#sources-panel-header button {
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

#sources-panel-content {
    padding: 14px;
    overflow-y: auto;
    flex: 1;
}

.source-side-item {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.source-side-title {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.source-side-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.source-side-desc {
    font-size: 12px;
    color: var(--text-main);
    margin-bottom: 8px;
}

.source-side-link {
    color: var(--verde-principal);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}

.source-side-link:hover { text-decoration: underline; }

.sources-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 30px 10px;
}

/* INPUT */
#input-area { padding: 24px; background: transparent; display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
#input-wrapper {
    width: 100%;
    max-width: 850px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 10px 16px;
    box-shadow: 0 4px 18px rgba(0,0,0,.06);
    transition: border-color 0.3s, box-shadow 0.3s;
}
#input-wrapper:focus-within {
    border-color: var(--verde-principal);
    box-shadow: 0 4px 18px rgba(39,174,96,.12);
}
#query-input {
    width: 100%; border: none; outline: none; padding: 10px 0; font-size: 15px;
    background: transparent; color: var(--text-main); resize: none; min-height: 40px; max-height: 160px; font-family: inherit;
}
#query-input::placeholder { color: var(--text-muted); }
#input-toolbar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.input-tool-btn {
    background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 8px;
    display: flex; align-items: center; gap: 5px; border-radius: 8px; transition: color 0.2s, background 0.2s;
}
.input-tool-btn:hover { color: var(--primary-color); background: var(--bg-light); }
.input-tool-btn:disabled { opacity: .45; cursor: default; }
#send-btn {
    margin-left: auto; background: var(--primary-color); color: white; border: none; border-radius: 8px;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: all 0.2s; box-shadow: 0 2px 5px rgba(39, 174, 96, 0.3);
}
#send-btn:hover { background: var(--primary-color-hover); transform: scale(1.05); }
#send-btn:disabled { opacity: .55; cursor: default; transform: none; }
#input-hint { font-size: 12px; color: var(--text-muted); margin-top: 10px; text-align: center; }

/* LOGIN */
#login-overlay {
    position: fixed; inset: 0; background-color: rgba(44, 62, 80, 0.8); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 1000; transition: opacity 0.3s ease;
}
#login-overlay.hidden { display: none; }
#login-card {
    background: var(--card-bg); width: 380px; border-radius: 16px; box-shadow: 0 15px 35px rgba(0,0,0,.2);
    padding: 36px; text-align: center; display: flex; flex-direction: column; align-items: stretch; border-top: 5px solid var(--verde-principal);
}
.login-logo-wrap { text-align: center; margin-bottom: 16px; }
.login-logo-wrap img, .logo-fallback { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 3px solid var(--cinza-borda); padding: 2px; }
.logo-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--verde-principal); color: #fff; font-weight: 700; }
#login-card h5 { font-size: 20px; font-weight: 700; margin: 0 0 4px; color: var(--text-main); text-align: center; }
.login-subtitle { font-size: 14px; color: var(--primary-color); font-weight: 600; margin: 0 0 24px; text-align: center; }
.login-field { width: 100%; text-align: left; margin-bottom: 16px; position: relative; }
.login-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-main); }
.login-input-wrap { display: flex; align-items: center; background-color: var(--bg-light); border: 1px solid var(--border-color); border-radius: 8px; }
.login-input-wrap:focus-within { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(39,174,96,.15); background:#fff; }
.login-input-wrap input { flex: 1; padding: 12px 14px; border: none; outline: none; background: transparent; font-size: 14px; color: var(--text-main); }
.login-input-wrap button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0 12px; }
#btn-login-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
#btn-login-submit {
    width: 100%; background-color: var(--primary-color); color: white; border: none; border-radius: 8px; padding: 12px;
    font-size: 15px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.2s; margin-top: 12px; box-shadow: 0 4px 10px rgba(39,174,96,.2);
}
#btn-login-submit:hover { background-color: var(--primary-color-hover); transform: translateY(-2px); }
#login-error { display: none; margin-top: 12px; padding: 8px 12px; background: rgba(220,53,69,.12); border: 1px solid rgba(220,53,69,.3); border-radius: 8px; font-size: 13px; color: #b02a37; text-align: center; }
#login-error.show { display: block; }
.login-footer-note { margin-top: 24px; font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.5; }

/* MENUS */
.filter-wrapper, .export-wrapper { position: relative; }
.options-menu-popup, .export-menu-popup {
    display: none; position: absolute; bottom: calc(100% + 8px); left: 0; background: #fff;
    border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.10); z-index: 300;
}
.options-menu-popup { width: 500px; padding: 12px; overflow: hidden; min-width: 360px; }
.export-menu-popup { width: 180px; padding: 6px; }
.filter-header { font-size: 13px; font-weight: 700; color: var(--primary-color); margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border-color); }
.filter-label { font-size: 12px; font-weight: 600; color: var(--text-main); margin-top: 8px; margin-bottom: 4px; display: block; }
.filter-select { display: none; }
.custom-select-wrap { position: relative; width: 100%; }
.custom-select-btn { width: 100%; background: var(--bg-light); border: 1px solid var(--border-color); border-radius: 8px; padding: 7px 28px 7px 10px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.custom-select-list { display: none; position: fixed; background: #fff; border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 9000; max-height: 200px; overflow-y: auto; min-width: 200px; }
.custom-select-list.open { display: block; }
.custom-select-option { padding: 8px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.custom-select-option:hover, .custom-select-option.selected { background: rgba(39,174,96,.12); color: var(--verde-escuro); font-weight: 600; }
.export-menu-item { width: 100%; background: none; border: none; color: var(--text-main); font-size: 13px; padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.export-menu-item:hover { background: var(--bg-light); color: var(--primary-color); }
.export-menu-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

.source-docs-container { margin-top: 12px; border-top: 1px solid var(--border-color); padding-top: 10px; }
.source-docs-title { display: flex; justify-content: space-between; cursor: pointer; font-size: 13px; color: var(--text-main); }
.source-docs-content { max-height: 0; overflow: hidden; transition: max-height .3s ease; border-left: 2px solid var(--verde-principal); padding-left: 10px; margin-top: 8px; }
.source-docs-content.show { max-height: 1500px; }
.source-doc { font-size: 13px; padding: 6px 0; color: var(--text-main); }
.source-doc a { color: var(--primary-color); text-decoration: none; font-size: 12px; }

#toast-container { position: fixed; bottom: 125px; right: 24px; z-index: 5000; display: flex; flex-direction: column; gap: 7px; }
.toast-msg { background:#fff; color:var(--text-main); border:1px solid var(--border-color); font-size:13px; padding:9px 15px; border-radius:8px; box-shadow:0 4px 16px rgba(0,0,0,.12); }

@media (max-width: 640px) {
    #sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 500; }
    .msg-bubble { max-width: 92%; }
    .options-menu-popup, .export-menu-popup { max-width: calc(100vw - 32px); }
}

/* =====================================================
   RODAPÉ
===================================================== */

#footer-app {
    position: fixed;
    left: 260px;
    right: 0;
    bottom: 0;
    height: 100px;

    background: #f5f7fa;
    border-top: 1px solid #e0e0e0;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    z-index: 50;
}

.footer-logo-unica {
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-logo-unica img {
    height: 42px;
    max-width: 100%;
    object-fit: contain;
    opacity: 0.9;
}

.footer-copy {
    font-size: 12px;
    color: #2c3e50;
    margin-top: 6px;
    text-align: center;
}