/* ARQUIVO: style.css - ATUALIZADO (V2) */

:root {
    /* --- Paleta Enterprise Original --- */
    --primary-color: #2563eb;       /* Azul Royal Principal */
    --primary-hover: #1d4ed8;       /* Azul Escuro (Hover) */
    --secondary-color: #64748b;     /* Cinza Azulado */
    
    --background-body: #f1f5f9;     /* Fundo da Página */
    --surface-card: #ffffff;        /* Fundo dos Cards */
    --text-main: #0f172a;           /* Texto Escuro */
    --text-muted: #64748b;          /* Texto Secundário */

    /* --- Cores de Status (Badges e Avisos) --- */
    --status-ok-bg: #dcfce7;      --status-ok-text: #166534; /* Verde */
    --status-warning-bg: #fef9c3; --status-warning-text: #854d0e; /* Amarelo */
    --status-danger-bg: #fee2e2;  --status-danger-text: #991b1b; /* Vermelho */
    --status-info-bg: #e0f2fe;    --status-info-text: #075985; /* Azul Claro */

    /* --- Dimensões e Efeitos --- */
    --sidebar-width: 260px;
    --header-height: 70px;
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset Básico --- */
* { box-sizing: border-box; outline: none; }

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--background-body); 
    color: var(--text-main); 
    margin: 0; 
    display: flex; 
    height: 100vh; 
    overflow: hidden; 
}

/* --- TELA DE CARREGAMENTO (LOADER) --- */
#loader-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #ffffff; z-index: 9999;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 0.8s ease-out;
}

.loader-content { text-align: center; }

.loader-title { 
    font-size: 1.5rem; font-weight: 700; color: #0f172a; 
    margin-bottom: 10px; display: flex; align-items: center; gap: 10px; justify-content: center; 
}

.loader-divider { 
    height: 3px; width: 100px; background: var(--primary-color); 
    margin: 15px auto; border-radius: 2px; 
}

.loader-text { 
    font-size: 0.9rem; color: #64748b; margin-top: 20px; font-weight: 500; 
    animation: pulseText 1.5s infinite;
}

@keyframes pulseText { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

.loader {
  width: 50px; aspect-ratio: 1; display: grid;
  border: 4px solid #0000; border-radius: 50%;
  border-color: #2563eb #0000; 
  animation: l16 1s infinite linear; margin: 0 auto;
}
.loader::before, .loader::after {    
  content: ""; grid-area: 1/1; margin: 2px; border: inherit; border-radius: 50%;
}
.loader::before { border-color: #22c55e #0000; animation: inherit; animation-duration: .5s; animation-direction: reverse; }
.loader::after { margin: 8px; border-color: #ef4444 #0000; }
@keyframes l16 { 100%{transform: rotate(1turn)} }

/* --- Scrollbar Customizada --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- Ícones & Utilitários --- */
.icon, .icon-sm, .icon-lg { display: inline-block; vertical-align: middle; transition: var(--transition-smooth); }
.icon { width: 20px; height: 20px; } 
.icon-sm { width: 16px; height: 16px; } 
.icon-lg { width: 24px; height: 24px; }

.icon-blue { filter: invert(30%) sepia(98%) saturate(1633%) hue-rotate(204deg) brightness(93%) contrast(96%); }
.icon-green { filter: invert(36%) sepia(50%) saturate(1475%) hue-rotate(99deg) brightness(93%) contrast(96%); }
.icon-red { filter: invert(28%) sepia(86%) saturate(2283%) hue-rotate(338deg) brightness(92%) contrast(88%); }
.icon-dark { filter: brightness(0.2); }
.icon-white { filter: brightness(0) invert(1); }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width); background: #0f172a; color: white; 
    display: flex; flex-direction: column; flex-shrink: 0; 
    transition: var(--transition-smooth); z-index: 50;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}
.sidebar-header { height: var(--header-height); display: flex; align-items: center; padding: 0 24px; border-bottom: 1px solid #1e293b; }
.logo-text { font-weight: 700; font-size: 1.1rem; display: flex; gap: 10px; align-items: center; }
.menu-list { list-style: none; padding: 20px 12px; margin: 0; flex-grow: 1; }
.link-menu { text-decoration: none; display: block; margin-bottom: 6px; }
.menu-item {
    padding: 12px 16px; border-radius: 8px; 
    color: #94a3b8; font-weight: 500; font-size: 0.95rem;
    display: flex; align-items: center; gap: 12px; 
    transition: var(--transition-smooth); cursor: pointer;
}
.menu-item:hover { background: rgba(255,255,255,0.05); color: #f1f5f9; }
.menu-item.active { background: var(--primary-color); color: white; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4); }
.menu-item .icon { filter: invert(66%) sepia(13%) saturate(464%) hue-rotate(182deg) brightness(90%) contrast(87%); opacity: 0.7; }
.menu-item:hover .icon, .menu-item.active .icon { filter: brightness(0) invert(1); opacity: 1; }

/* --- Main Content --- */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.top-bar {
    height: var(--header-height); background: white; border-bottom: 1px solid #e2e8f0; 
    display: flex; align-items: center; justify-content: space-between; 
    padding: 0 32px; flex-shrink: 0;
}
.container { padding: 32px; overflow-y: auto; flex: 1; max-width: 1600px; margin: 0 auto; width: 100%; }

/* --- Cards --- */
.card { 
    background: var(--surface-card); border-radius: 12px; 
    padding: 24px; box-shadow: var(--shadow-card); 
    border: 1px solid #e2e8f0; margin-bottom: 24px; 
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
h3, h4 { margin-top: 0; color: var(--text-main); font-weight: 600; display: flex; align-items: center; }

/* --- KPIs Interativos --- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin-bottom: 32px; }

.kpi-card {
    background: white; padding: 24px; border-radius: 12px; 
    border-left: 5px solid var(--primary-color);
    box-shadow: var(--shadow-card); 
    display: flex; flex-direction: column; justify-content: space-between;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer; /* Indica interatividade */
}
.kpi-card:hover { 
    transform: translateY(-5px); 
    box-shadow: var(--shadow-hover);
}
/* Efeito de "clique" no KPI */
.kpi-card:active { transform: translateY(-2px); }

.kpi-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.kpi-value { font-size: 2rem; font-weight: 800; color: var(--text-main); }

/* --- Tabelas --- */
.table-responsive { overflow-x: auto; border-radius: 8px; border: 1px solid #e2e8f0; }
table { width: 100%; border-collapse: collapse; background: white; min-width: 700px; }
thead th { 
    background: #f8fafc; color: #475569; font-weight: 700; font-size: 0.75rem; 
    text-transform: uppercase; padding: 16px; text-align: left; 
    border-bottom: 2px solid #e2e8f0; white-space: nowrap; 
}
tbody td { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; color: #334155; vertical-align: middle; }
tbody tr { transition: background-color 0.2s; }
tbody tr:hover { background-color: #f8fafc; }

/* --- Badges --- */
.badge { 
    padding: 4px 10px; border-radius: 20px; 
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase; 
    display: inline-flex; align-items: center; gap: 5px;
}
.bg-success { background: var(--status-ok-bg); color: var(--status-ok-text); }
.bg-warning { background: var(--status-warning-bg); color: var(--status-warning-text); }
.bg-danger { background: var(--status-danger-bg); color: var(--status-danger-text); }
.bg-info { background: var(--status-info-bg); color: var(--status-info-text); }

/* --- Calendário --- */
.calendar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(75px, 1fr)); gap: 10px; margin-bottom: 20px; }
.month-card {
    background: white; border: 1px solid #cbd5e1; border-radius: 8px; 
    padding: 12px 5px; text-align: center; cursor: pointer; 
    font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
    transition: all 0.2s ease; user-select: none;
}
.month-card:hover { border-color: var(--primary-color); color: var(--primary-color); transform: translateY(-2px); }
.month-card.active { 
    background: var(--primary-color); color: white; border-color: var(--primary-color); 
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4); transform: translateY(-2px);
}

/* --- Botões --- */
.btn-primary { 
    background: var(--primary-color); color: white; padding: 10px 20px; border-radius: 6px; 
    font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer; 
    display: flex; align-items: center; gap: 8px; transition: var(--transition-smooth); 
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; transform: none; }

.btn-action { 
    width: 30px; height: 30px; border-radius: 6px; border: none; 
    cursor: pointer; margin-right: 6px; 
    display: inline-flex; align-items: center; justify-content: center; 
    font-weight: bold; transition: all 0.2s;
}
.btn-add { background: #dcfce7; color: #15803d; } .btn-add:hover { background: #bbf7d0; }
.btn-sub { background: #fee2e2; color: #b91c1c; } .btn-sub:hover { background: #fecaca; }
.btn-del { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }
.btn-del:hover { background: #fee2e2; color: #ef4444; border-color: #fecaca; }

.btn-toggle-menu { display: none; }

/* --- Modal --- */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(15, 23, 42, 0.7); z-index: 100; 
    display: none; align-items: center; justify-content: center; 
    backdrop-filter: blur(4px); 
}
.modal-overlay.open { display: flex; }

.modal-window { 
    background: white; width: 90%; max-width: 450px; 
    border-radius: 12px; overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-top: 6px solid var(--primary-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

.modal-header { padding: 20px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; background: #f8fafc; display: flex; justify-content: flex-end; gap: 10px; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; margin-bottom: 0; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: #334155; }

/* NOVO: Botão Fechar Modal Sofisticado */
.btn-close-modal {
    background: transparent; border: none; cursor: pointer; 
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #94a3b8; transition: all 0.2s; font-size: 1.1rem;
}
.btn-close-modal:hover { background: #f1f5f9; color: #ef4444; transform: rotate(90deg); }

/* --- NOVO: Toast Notification (Substitui Alert) --- */
#toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 9999;
    display: flex; flex-direction: column; gap: 10px;
}

.toast {
    background: white; border-left: 4px solid #22c55e;
    padding: 16px 20px; border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    display: flex; align-items: center; gap: 12px;
    min-width: 300px;
    transform: translateX(120%); transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show { transform: translateX(0); }
.toast-icon { color: #22c55e; font-size: 1.2rem; }
.toast-content h4 { margin: 0; font-size: 0.95rem; color: #0f172a; }
.toast-content p { margin: 3px 0 0 0; font-size: 0.85rem; color: #64748b; }

/* --- Tooltip/Info Box para KPIs --- */
.info-tooltip {
    display: none;
    position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    background: #1e293b; color: white; padding: 10px; border-radius: 6px;
    font-size: 0.8rem; width: 220px; text-align: center; z-index: 10;
    margin-top: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.info-tooltip::after {
    content: ""; position: absolute; bottom: 100%; left: 50%; margin-left: -5px;
    border-width: 5px; border-style: solid; border-color: transparent transparent #1e293b transparent;
}
.kpi-card:hover .info-tooltip { /* Caso queira via CSS puro, mas faremos via JS click */ }

/* --- Responsividade --- */
@media (max-width: 768px) {
    .sidebar { position: fixed; height: 100%; transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); }
    .btn-toggle-menu { display: block; background: none; border: none; cursor: pointer; font-size: 1.2rem; }
    .kpi-grid { grid-template-columns: 1fr; }
    .top-bar { padding: 0 16px; }
    .container { padding: 16px; }
}

.kpi-info-box-detalhe {
    display: none; /* Oculto por padrão */
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
    color: #334155;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

.kpi-info-box-detalhe.active {
    display: block; /* Mostra quando tem a classe active */
}

.kpi-info-box-detalhe h4 { 
    font-size: 1rem; 
    margin-bottom: 8px; 
    color: var(--primary-color);
}

.kpi-info-box-detalhe ul { 
    padding-left: 20px; 
    margin: 5px 0; 
}

.kpi-info-box-detalhe li { 
    margin-bottom: 4px; 
    color: var(--text-muted);
}
.kpi-info-box-detalhe li strong {
    color: var(--text-main);
}

@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(-5px); } 
    to { opacity: 1; transform: translateY(0); } 
}
