﻿/* Variáveis CSS */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;

    /* Layout (estavam sendo usadas mas NUNCA foram definidas) */
    --sidebar-w: 260px;
    --topbar-h: 56px;
    --sidebar-bg: #111827;
    --bg-surface: #ffffff;
    --border: #dee2e6;
    --radius: 6px;
    --transition: .2s ease;
    --accent: #0d6efd;
    --accent-hover: #6ea8fe;
    --purple: #6f42c1;
    --info: #0dcaf0;
    --danger: #dc3545;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #6b7280;
}

/* Reset e Base */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin-bottom: 60px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Layout */
main {
    min-height: calc(100vh - 160px);
}

.footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    white-space: nowrap;
    line-height: 60px;
}

/* Navbar Customização */
.navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9);
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: #fff;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    /* dentro da sidebar o tema é escuro: redefine as variáveis de texto */
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border: rgba(255, 255, 255, .10);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-brand-sub {
    font-size: .68rem;
    color: var(--text-muted);
    margin-top: -2px;
}

.sidebar-Financeiro {
    padding: 10px 16px;
    background: rgba(31,111,235,.08);
    border-bottom: 1px solid var(--border);
    font-size: .75rem;
    color: var(--text-secondary);
}

    .sidebar-Financeiro strong {
        color: var(--info);
        font-size: .8rem;
    }

.sidebar-nav {
    flex: 1;
    min-height: 0;          /* permite o scroll interno do flex */
    padding: 8px 0;
    overflow-y: auto;
}
/* ── Main area ──────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-topbar {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius);
    font-size: 1rem;
    transition: all var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .btn-topbar:hover {
        background: rgba(0,0,0,.06);
        color: var(--text-primary);
    }

.nav-section-title {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 16px 4px;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .875rem;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

    .nav-item-link:hover {
        background: rgba(255,255,255,.05);
        color: var(--text-primary);
    }

    .nav-item-link.active {
        background: rgba(31,111,235,.15);
        color: var(--accent-hover);
    }

        .nav-item-link.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 3px;
            background: var(--accent);
            border-radius: 0 2px 2px 0;
        }

.nav-icon {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* Sub-menu */
.nav-submenu {
    list-style: none;
}

    .nav-submenu .nav-item-link {
        padding-left: 44px;
        font-size: .825rem;
    }

.nav-submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

    .nav-submenu-toggle .nav-arrow {
        font-size: .7rem;
        transition: transform var(--transition);
        color: var(--text-muted);
    }

    .nav-submenu-toggle[aria-expanded="true"] .nav-arrow {
        transform: rotate(90deg);
    }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: .78rem;
    color: var(--text-muted);
}

    .sidebar-footer a {
        color: var(--text-muted);
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 0;
        transition: color var(--transition);
    }

        .sidebar-footer a:hover {
            color: var(--danger);
        }

/* Cards */
.card {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.card-header {
    background-color: var(--light-color);
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
}

/* Botões */
.btn {
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-weight: 500;
}

.btn-icon {
    padding: 0.375rem 0.75rem;
}

/* Tabelas */
.table-responsive {
    border-radius: 8px;
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: var(--light-color);
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Badges de Status */
.badge {
    padding: 0.35em 0.65em;
    font-weight: 500;
}

.status-aberta {
    background-color: var(--info-color);
    color: #000;
}

.status-paga {
    background-color: var(--success-color);
}

.status-vencida {
    background-color: var(--danger-color);
}

.status-parcial {
    background-color: var(--warning-color);
    color: #000;
}

.status-cancelada {
    background-color: var(--secondary-color);
}

/* Formulários */
.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-control, .form-select {
    border-radius: 6px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.invalid-feedback {
    display: block;
}

/* Dashboard Cards */
.dashboard-card {
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.dashboard-card .card-body {
    padding: 1.5rem;
}

.dashboard-card .display-4 {
    font-size: 2.5rem;
    font-weight: 700;
}

.dashboard-card.card-primary {
    border-left-color: var(--primary-color);
}

.dashboard-card.card-success {
    border-left-color: var(--success-color);
}

.dashboard-card.card-danger {
    border-left-color: var(--danger-color);
}

.dashboard-card.card-warning {
    border-left-color: var(--warning-color);
}

/* Upload de Arquivos */
.file-upload-area {
    border: 2px dashed var(--primary-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    background-color: rgba(13, 110, 253, 0.05);
    cursor: pointer;
    transition: all 0.3s;
}

.file-upload-area:hover {
    background-color: rgba(13, 110, 253, 0.1);
    border-color: var(--primary-color);
}

.file-upload-area.dragging {
    background-color: rgba(13, 110, 253, 0.15);
    border-color: var(--success-color);
}

/* Lista de Documentos */
.documento-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

.documento-item:hover {
    background-color: var(--light-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.documento-icon {
    font-size: 2rem;
    margin-right: 1rem;
    color: var(--primary-color);
}

.documento-info {
    flex: 1;
}

.documento-nome {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.documento-meta {
    font-size: 0.875rem;
    color: var(--secondary-color);
}

/* Responsive */
@media (max-width: 767px) {
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .dashboard-card .display-4 {
        font-size: 2rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* Utilities */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* Print */
@media print {
    .navbar, .footer, .btn, .no-print {
        display: none !important;
    }
    
    body {
        margin: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
}


/* ── Topbar: usuário ────────────────────────────────────────── */
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .875rem;
    color: var(--text-primary);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Sidebar: botão Sair ────────────────────────────────────── */
.btn-logout {
    background: none;
    border: none;
    padding: 4px 0;
    width: 100%;
    text-align: left;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    transition: color var(--transition);
}

    .btn-logout:hover {
        color: #f87171;
    }

/* ── Sidebar recolhida / sem sidebar (DEVE ficar após .main-content) ── */
.main-content.no-sidebar {
    margin-left: 0;
}

@media (min-width: 769px) {
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-collapsed .main-content {
        margin-left: 0;
    }
}

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

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

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

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mapa-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    }
}
