/* ========================================
   ESTILOS GLOBAIS
   ======================================== */

/* Body - Font family e background */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f8fafc;
}

/* ========================================
   SIDEBAR STYLES
   ======================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    z-index: 1000;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    padding: 20px 0;
    flex-grow: 1;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 12px 20px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border-left-color: white;
}

.sidebar-nav .nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    border-left-color: white;
}

.sidebar-nav .nav-link i {
    margin-right: 10px;
    width: 20px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main Content */
.main-content {
    margin-left: 250px;
    min-height: 100vh;
    background-color: #f8f9fa;
}

/* Dashboard Cards */
.dashboard-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    transition: transform 0.3s ease;
}

.dashboard-card:hover {
    transform: translateY(-5px);
}

.dashboard-card .card-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.dashboard-card .card-value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.dashboard-card .card-label {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

/* Custom Colors */
.text-success {
    color: #28a745 !important;
}

.text-danger {
    color: #dc3545 !important;
}

/* Estilos para gráficos profissionais */
.chart-container {
    position: relative;
    height: 100%;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin: 10px 0;
}

.chart-container canvas {
    max-height: 100%;
    width: 100% !important;
    height: auto !important;
    border-radius: 8px;
}

/* Melhorias para badges dos gráficos */
.chart-badge {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chart-badge i {
    font-size: 0.8rem;
}

/* Melhorias para tooltips */
.chart-tooltip {
    background: rgba(0, 0, 0, 0.95) !important;
    border: 3px solid #1976d2 !important;
    border-radius: 12px !important;
    color: white !important;
    font-weight: 600 !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(10px);
}

/* Estilos para legenda de alocação */
.allocation-legend {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.allocation-legend-item {
    transition: all 0.3s ease;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.allocation-legend-item:hover {
    background: rgba(44, 85, 48, 0.05);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.allocation-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Animações suaves para gráficos */
.chart-animation {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animação de spin para ícones de atualização */
.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Melhorias para responsividade dos gráficos */
@media (max-width: 768px) {
    .chart-container {
        min-height: 250px;
    }

    .allocation-legend {
        font-size: 0.875rem;
    }

    .chart-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

/* Estilos para gráficos de barras horizontais */
.horizontal-bar-chart {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.horizontal-bar-chart .chart-title {
    color: #2c5530;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 16px;
}

/* Melhorias para canvas do Chart.js */
canvas {
    border-radius: 8px;
}

/* Estilos para loading dos gráficos */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6c757d;
}

.chart-loading .spinner-border {
    width: 2rem;
    height: 2rem;
    margin-right: 0.5rem;
}

/* Melhorias específicas para o gráfico de evolução */
.evolucao-chart-container {
    position: relative;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.evolucao-chart-container svg {
    width: 100% !important;
    height: 100% !important;
    border-radius: 8px;
}

/* Melhorias para o gráfico de alocação */
.alocacao-chart-container {
    position: relative;
    height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.alocacao-chart-container svg {
    width: 100% !important;
    height: 100% !important;
    border-radius: 8px;
}

/* Estilos para elementos D3 */
.bar {
    transition: all 0.3s ease;
}

.bar:hover {
    opacity: 0.8;
    transform: scale(1.02);
}

.line {
    stroke-linecap: round;
    stroke-linejoin: round;
}

.point {
    transition: all 0.3s ease;
    cursor: pointer;
}

.point:hover {
    stroke-width: 4;
}

.area {
    opacity: 0.1;
}

/* Melhorias para textos no gráfico de alocação */
.bar-text {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.connector {
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.connector:hover {
    opacity: 1;
}

/* Tooltip personalizado */
.tooltip {
    background: rgba(0, 0, 0, 0.95) !important;
    border: 2px solid #1976d2 !important;
    border-radius: 8px !important;
    color: white !important;
    font-weight: 600 !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(10px);
    padding: 12px !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
}

/* Grid lines */
.grid line {
    stroke: rgba(0, 0, 0, 0.1);
    stroke-width: 1;
}

.grid path {
    stroke-width: 0;
}

/* Eixos */
.axis text {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    font-weight: 500;
    fill: #666;
}

.axis path,
.axis line {
    stroke: rgba(0, 0, 0, 0.2);
    stroke-width: 1;
}

/* Melhorias para responsividade dos gráficos D3 */
@media (max-width: 1200px) {
    .evolucao-chart-container {
        height: 350px;
        padding: 15px;
    }

    .alocacao-chart-container {
        height: 320px;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .evolucao-chart-container {
        height: 300px;
        padding: 10px;
    }

    .alocacao-chart-container {
        height: 280px;
        padding: 10px;
    }

    .axis text {
        font-size: 10px;
    }

    .tooltip {
        font-size: 11px !important;
        padding: 8px !important;
    }
}

/* Melhorias para os cards dos gráficos */
.bg-white.rounded-4.shadow-sm.p-4.h-100.chart-animation {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.bg-white.rounded-4.shadow-sm.p-4.h-100.chart-animation:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15) !important;
    transform: translateY(-2px);
}

/* Melhorias para títulos dos gráficos */
.fw-semibold.fs-5 {
    color: #2c5530 !important;
    font-weight: 700 !important;
    margin-bottom: 1rem !important;
}

/* Melhorias para loading states */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6c757d;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    backdrop-filter: blur(5px);
}

.chart-loading .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    margin-right: 0.75rem;
    color: #2c5530 !important;
}

.chart-loading span {
    font-weight: 500;
    color: #2c5530;
}

/* Melhorias para estados de erro */
.chart-loading .text-danger {
    color: #dc3545 !important;
    font-weight: 600;
}

.chart-loading .text-muted {
    color: #6c757d !important;
    font-weight: 500;
}

/* Tables */
.table th {
    border-top: none;
    font-weight: 600;
    color: #495057;
}

/* Forms */
.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Buttons */
.btn-primary {
    background-color: #667eea;
    border-color: #667eea;
}

.btn-primary:hover {
    background-color: #5a6fd8;
    border-color: #5a6fd8;
}

/* ========================================
   KPI CARD - COMPONENTE GLOBAL
   Usado em múltiplas páginas (Lançamentos, Fluxo, Contas, etc)
   ======================================== */

.kpi-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
}

/* Cards com botões precisam de overflow: visible */
.conta-card,
.cartao-card {
    overflow: visible;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, var(--accent-color, #16a34a), var(--accent-color-light, #22a06b));
}

/* Responsividade para KPI Cards */
@media (max-width: 768px) {
    .kpi-card {
        padding: 1.25rem;
    }
}

@media (max-width: 576px) {
    .kpi-card {
        padding: 1rem;
    }
}

/* ========================================
   DESIGN TOKENS - CORES GLOBAIS
   ======================================== */

:root {
    /* Cores principais do sistema */
    --color-success: #16a34a;
    --color-success-light: #22c55e;
    --color-success-dark: #15803d;

    --color-danger: #dc2626;
    --color-danger-light: #ef4444;
    --color-danger-dark: #b91c1c;

    --color-warning: #eab308;
    --color-warning-light: #f59e0b;
    --color-warning-dark: #d97706;

    --color-info: #3b82f6;
    --color-info-light: #60a5fa;
    --color-info-dark: #2563eb;

    --color-primary: #2c5530;
    --color-primary-light: #22543d;
    --color-primary-dark: #1e3a28;

    /* Cores de fundo */
    --bg-success: #dcfce7;
    --bg-danger: #fee2e2;
    --bg-warning: #fef3c7;
    --bg-info: #e0f2fe;

    /* Cores neutras */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

/* ========================================
   CLASSES UTILITÁRIAS DE ACENTO
   (Compartilhadas entre múltiplas páginas)
   ======================================== */

.accent-verde-escuro {
    --accent-color: #2c5530;
    --accent-color-light: #22543d;
}

.accent-verde {
    --accent-color: #16a34a;
    --accent-color-light: #15803d;
}

.accent-azul {
    --accent-color: #3b82f6;
    --accent-color-light: #2563eb;
}

.accent-vermelho {
    --accent-color: #dc2626;
    --accent-color-light: #b91c1c;
}

.accent-cinza {
    --accent-color: #6b7280;
    --accent-color-light: #9ca3af;
}