:root {
    --sele-dark: #1E2A38;
    --sele-accent: #3B82F6;
    --sidebar-w: 240px;
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f0f2f5; }

/* ---- Layout ---- */
.admin-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sele-dark);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    flex-direction: column;
}
.sidebar-logo  { font-size: 2rem; line-height: 1; }
.sidebar-title { font-size: 1.1rem; font-weight: 700; color: #fff; margin-top: .25rem; }
.sidebar-subtitle { color: #94a3b8; font-size: .75rem; }

.sidebar .nav-link {
    color: #cbd5e1;
    padding: .6rem 1rem;
    border-radius: .4rem;
    margin: .1rem .5rem;
    transition: background .15s;
}
.sidebar .nav-link:hover  { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-link.active { background: var(--sele-accent); color: #fff; }
.sidebar .nav-link i      { margin-right: .5rem; width: 1.2rem; }

.sidebar-footer { margin-top: auto; padding: 1rem; }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 1.5rem 2rem;
    min-height: 100vh;
}

/* ---- Login ---- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sele-dark);
}
.login-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-icon   { font-size: 3rem; }
.login-header h1 { font-size: 1.5rem; margin-top: .5rem; color: var(--sele-dark); }

/* ---- Page header ---- */
.page-header { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid #dee2e6; }
.page-header h2 { font-size: 1.5rem; color: var(--sele-dark); margin: 0; }

/* ---- Stat cards ---- */
.stat-card {
    background: #fff;
    border-radius: .75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    height: 100%;
}
.stat-icon  { font-size: 1.75rem; margin-bottom: .5rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--sele-dark); }
.stat-label { font-size: .8rem; color: #64748b; text-transform: uppercase; letter-spacing: .05em; }

/* ---- Cards e tables ---- */
.card { border: none; box-shadow: 0 1px 4px rgba(0,0,0,.08); border-radius: .75rem; }
.table th { font-size: .8rem; text-transform: uppercase; color: #64748b; letter-spacing: .05em; font-weight: 600; }

/* ---- Modal custom ---- */
.modal-backdrop-custom {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-dialog-custom {
    background: #fff;
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-dialog-custom h5 { margin-bottom: 1.25rem; color: var(--sele-dark); }

/* ---- Font-monospace para API keys ---- */
.font-monospace { font-family: 'Cascadia Code', 'Consolas', monospace; word-break: break-all; }

/* ===================== CHAT ASSISTENTE ===================== */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 220px);
    min-height: 400px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: .75rem;
    border: 1px solid #dee2e6;
    margin-bottom: 1rem;
    scroll-behavior: smooth;
}

/* Welcome */
.chat-welcome {
    text-align: center;
    padding: 3rem 2rem;
    color: #64748b;
}
.chat-welcome .welcome-icon { font-size: 3rem; margin-bottom: 1rem; }
.chat-welcome h5 { color: var(--sele-dark); }

.sugestoes {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: center;
    margin-top: 1.5rem;
}
.sugestao {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 2rem;
    padding: .4rem 1rem;
    font-size: .85rem;
    color: var(--sele-dark);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.sugestao:hover { background: var(--sele-dark); color: #fff; border-color: var(--sele-dark); }

/* Bubbles */
.chat-bubble {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1rem;
}
.bubble-user     { flex-direction: row-reverse; }
.bubble-assistant { flex-direction: row; }

.bubble-avatar {
    font-size: 1.4rem;
    flex-shrink: 0;
    margin-top: .25rem;
}

.bubble-content {
    max-width: 80%;
    padding: .75rem 1rem;
    border-radius: 1rem;
    font-size: .9rem;
    line-height: 1.6;
}
.bubble-user .bubble-content {
    background: var(--sele-dark);
    color: #fff;
    border-bottom-right-radius: .25rem;
}
.bubble-assistant .bubble-content {
    background: #fff;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: .25rem;
    color: #1e2a38;
}
.bubble-erro .bubble-content {
    background: #fff3f3;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Markdown renderizado no bubble */
.bubble-content p     { margin-bottom: .5rem; }
.bubble-content p:last-child { margin-bottom: 0; }
.bubble-content code  { background: #f1f5f9; border-radius: .25rem; padding: .1rem .3rem; font-size: .85em; }
.bubble-content table { font-size: .82rem; }
.bubble-content ul    { margin-bottom: .5rem; padding-left: 1.25rem; }
.bubble-content h4, .bubble-content h5, .bubble-content h6 { margin-top: .75rem; margin-bottom: .25rem; }

/* Typing indicator */
.typing-indicator { display: inline-flex; align-items: center; gap: 4px; padding: .25rem 0; }
.typing-indicator span {
    width: 7px; height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing-bounce .8s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .30s; }
@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(1); opacity: .5; }
    40%           { transform: scale(1.3); opacity: 1; }
}

/* Input */
.chat-input-area { flex-shrink: 0; }
.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    background: #fff;
    border: 1.5px solid #dee2e6;
    border-radius: 1rem;
    padding: .5rem .75rem;
    transition: border-color .15s;
}
.chat-input-wrapper:focus-within { border-color: var(--sele-accent); }
.chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: .9rem;
    font-family: inherit;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.5;
    background: transparent;
}
.btn-enviar {
    background: var(--sele-dark);
    color: #fff;
    border: none;
    border-radius: .6rem;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
    font-size: 1rem;
}
.btn-enviar:hover:not(:disabled)  { background: var(--sele-accent); }
.btn-enviar:disabled { opacity: .4; cursor: not-allowed; }
