@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0');

:root {
    /* Fallbacks if not provided by Jinja */
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Typography Overrides */
h1, h2, h3, h4, h5, h6 { color: var(--text-primary); }

/* ==================== LOGIN PAGE ==================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-color);
}

.login-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 3rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.3s ease;
}

.btn:hover {
    filter: brightness(1.2);
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* ==================== DASHBOARD PAGE ==================== */
.dashboard-wrapper {
    flex-grow: 1;
    height: 100vh;
    position: relative;
    padding-left: 60px;
    overflow: hidden;
}

.iframe-container {
    width: 100%;
    height: 100%; /* Vamos usar o blocker para cobrir, em vez de empurrar, para ser mais preciso */
    border: none;
    display: block;
}

/* RODAPÉ PREMIUM (Substitui o antigo bloqueador) */
.powerbi-share-blocker {
    position: absolute;
    top: 0;
    left: 60px;
    right: 0;
    height: 38px; /* Altura reduzida para não obstruir ferramentas de zoom */
    background: #0a0f1e; /* Azul ultra escuro sólido */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 1000;
    pointer-events: auto; /* Bloqueia cliques nos botões de compartilhar por trás */
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.powerbi-share-blocker .footer-tag {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
}

.powerbi-share-blocker .footer-tag span {
    font-size: 16px;
    color: #10b981; /* Verde sucesso para o ícone de verificado */
}

.powerbi-share-blocker .footer-info {
    color: var(--text-secondary);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Loader */
.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-bottom-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    z-index: 10;
}

/* ==================== AI SIDEBAR (RIGHT) ==================== */
.ai-sidebar {
    position: fixed;
    top: 0; right: -400px;
    width: 400px;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(192, 132, 252, 0.2);
    z-index: 1001;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}

.ai-sidebar.open {
    right: 0;
}

.ai-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.1), transparent);
}

.ai-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    color: #c084fc;
}

.ai-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Chat Interface */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-right: 0.5rem;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.message {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    max-width: 85%;
    line-height: 1.4;
}

.message.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.ai {
    align-self: flex-start;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    background: rgba(0,0,0,0.2);
    padding: 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255,255,255,0.1);
}

.chat-input-area input {
    flex-grow: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 0.5rem;
    outline: none;
    font-size: 0.9rem;
}

.chat-send-btn {
    background: #8b5cf6;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    background: #a78bfa;
}

/* Executive Report Button */
.ai-report-btn {
    background: linear-gradient(135deg, #8b5cf6, #d946ef);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.ai-report-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    filter: brightness(1.1);
}

/* Activation Overlay */
.ai-activation-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    backdrop-filter: blur(10px);
}

.ai-activation-overlay h3 { color: #c084fc; margin-bottom: 1rem; }
.ai-activation-overlay p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 2rem; line-height: 1.5; }

.terms-container {
    background: rgba(0,0,0,0.2);
    padding: 1rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    text-align: left;
    margin-bottom: 1.5rem;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,0.05);
}

/* Trigger Button */
.ai-trigger-btn {
    position: fixed;
    bottom: 60px;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #d946ef);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-trigger-btn:hover {
    transform: scale(1.1) rotate(10deg);
}

@keyframes rotation {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 768px) {
    .login-card {
        margin: 1rem;
        padding: 2rem 1.25rem;
    }
}
