/* Estilos gerais */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --sidebar-width: 250px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fc;
    overflow-x: hidden;
    margin: 0;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #007bff, #0056b3);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
}

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

.loading-content .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Main Content */
.main-content {
    margin-top: 0px !important;
    padding: 20px;
    min-height: calc(100vh - 80px);
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Container adjustments */
.container-fluid {
    padding-left: 15px !important;
    padding-right: 15px !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* Row adjustments */
.row {
    margin-left: -15px !important;
    margin-right: -15px !important;
    width: calc(100% + 30px) !important;
}

.row > * {
    padding-left: 15px !important;
    padding-right: 15px !important;
}

/* Dashboard específico */
.content-section {
    animation: fadeIn 0.3s ease-in;
}

#dashboard-section {
    width: 100%;
    overflow-x: hidden;
}

#dashboard-section .row {
    margin-left: -15px;
    margin-right: -15px;
}

#dashboard-section .col-xl-3,
#dashboard-section .col-xl-4,
#dashboard-section .col-xl-8,
#dashboard-section .col-lg-5,
#dashboard-section .col-lg-7,
#dashboard-section .col-md-6,
#dashboard-section .col-12 {
    padding-left: 15px;
    padding-right: 15px;
}

/* Cards do Dashboard */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    transition: all 0.3s;
    margin-bottom: 1.5rem;
    width: 100%;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.25rem 2rem 0 rgba(58, 59, 69, 0.2);
}

.card-header {
    background-color: #f8f9fc;
    border-bottom: 1px solid #e3e6f0;
    border-radius: 10px 10px 0 0 !important;
    padding: 0.75rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* Ajuste para cards de métricas */
.card.border-left-primary,
.card.border-left-success,
.card.border-left-info,
.card.border-left-warning,
.card.border-left-danger {
    margin-bottom: 1rem;
}

/* Tabelas mais compactas */
.table-sm th,
.table-sm td {
    padding: 0.5rem;
    vertical-align: middle;
}

.table-responsive {
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
}

.table {
    margin-bottom: 0;
    width: 100%;
}

/* Filtros compactos */
.row.g-2 > * {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

.form-select-sm,
.form-control-sm {
    height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Container de títulos específico */
#titulosReceberTable {
    width: 100% !important;
}

#titulosReceberTable th,
#titulosReceberTable td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ajuste específico do resumo */
.alert-light {
    background-color: #f8f9fc;
    border-color: #e3e6f0;
    color: #495057;
}

/* Badges menores */
.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Botões de ação menores */
.btn-group-sm > .btn,
.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Estados vazios */
.text-center.py-5 {
    padding: 2rem 1rem !important;
}

/* Responsividade melhorada */
@media (max-width: 768px) {
    .main-content {
        padding: 15px 10px;
    }
    
    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    .row {
        margin-left: -10px !important;
        margin-right: -10px !important;
        width: calc(100% + 20px) !important;
    }
    
    .row > * {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    .card-body {
        padding: 1rem 0.75rem;
    }
    
    .btn-group-sm .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .table-sm th,
    .table-sm td {
        padding: 0.4rem 0.3rem;
        font-size: 0.85rem;
    }
    
    /* Cards de métricas em mobile */
    .col-xl-3.col-md-6 {
        margin-bottom: 1rem;
    }
    
    /* Filtros em mobile */
    .row.g-2 > * {
        margin-bottom: 0.5rem;
    }
}

/* Border Cards */
.border-left-primary {
    border-left: 0.25rem solid var(--primary-color) !important;
}

.border-left-success {
    border-left: 0.25rem solid var(--success-color) !important;
}

.border-left-info {
    border-left: 0.25rem solid var(--info-color) !important;
}

.border-left-warning {
    border-left: 0.25rem solid var(--warning-color) !important;
}

.border-left-danger {
    border-left: 0.25rem solid var(--danger-color) !important;
}

/* Dropdown Menu (usado no topbar) */
.dropdown-menu {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    z-index: 1050 !important;
}

.dropdown-item {
    transition: background-color 0.3s;
}

.dropdown-item:hover {
    background-color: #f8f9fc;
}

/* Tables */
.table {
    background-color: white;
}

.table thead th {
    background-color: #f8f9fc;
    border-bottom: 1px solid #e3e6f0;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.table tbody tr {
    transition: background-color 0.3s;
}

.table tbody tr:hover {
    background-color: #f8f9fc;
}

/* Buttons */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Forms */
.form-control {
    border-radius: 6px;
    border: 1px solid #d1d3e2;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.input-group-text {
    background-color: #f8f9fc;
    border: 1px solid #d1d3e2;
    color: var(--secondary-color);
}

/* Modal */
.modal-content {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

.modal-header {
    border-bottom: 1px solid #e3e6f0;
    border-radius: 10px 10px 0 0;
}

.modal-footer {
    border-top: 1px solid #e3e6f0;
    border-radius: 0 0 10px 10px;
}

/* Content Sections */
.content-section {
    animation: fadeIn 0.3s ease-in;
}

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

/* Status Badges */
.status-pago {
    background-color: var(--success-color);
}

.status-pendente {
    background-color: var(--warning-color);
}

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

.status-parcial {
    background-color: var(--info-color);
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    padding: 10px;
}

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

/* DataTables Customization */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_processing,
.dataTables_wrapper .dataTables_paginate {
    color: var(--dark-color);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.375rem 0.75rem;
    margin-left: 2px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    background-color: white;
    color: var(--primary-color);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 15px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table-responsive {
        border: none;
    }
    
    .h5 {
        font-size: 1.1rem;
    }
}

/* Utilities */
.text-xs {
    font-size: 0.7rem;
}

.font-weight-bold {
    font-weight: 700 !important;
}

.text-gray-800 {
    color: #5a5c69 !important;
}

.text-uppercase {
    text-transform: uppercase !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.action-buttons .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Filter Section */
.filter-section {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.filter-section .form-row {
    margin-bottom: 15px;
}

/* Quick Stats */
.quick-stats {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.quick-stats .stat-item {
    text-align: center;
    padding: 10px;
}

.quick-stats .stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    display: block;
}

.quick-stats .stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Success Messages */
.alert {
    border: none;
    border-radius: 8px;
}

.alert-success {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid var(--info-color);
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border-left: 4px solid var(--warning-color);
}

/* Loading States */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* Cards responsivos lado a lado */
@media (max-width: 991.98px) {
    .col-lg-6 .card {
        margin-bottom: 1rem;
    }
    
    /* Ajustes para tabelas em telas menores */
    .table-responsive {
        font-size: 0.85rem;
    }
    
    .btn-group .btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* Melhorias visuais para containers de contas */
.card-header .btn-group {
    gap: 0.25rem;
}

.card-body .alert {
    border-radius: 0.5rem;
}

.table th, .table td {
    vertical-align: middle;
}

.badge {
    font-size: 0.75rem;
}

/* Ajustes para filtros compactos */
.form-select-sm, .form-control-sm {
    font-size: 0.875rem;
}

.row.g-1 > * {
    padding-right: 0.125rem;
    padding-left: 0.125rem;
}

/* Estados vazios e loading mais compactos */
.text-center.py-3 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

.text-center.py-4 {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
}

/* Responsividade para botões */
@media (max-width: 576px) {
    .d-flex.flex-wrap.gap-1 {
        gap: 0.25rem !important;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* ===========================
   SIDEBAR LATERAL
   =========================== 
   
   Sistema de navegação lateral responsivo:
   - Desktop: Sidebar fixo à esquerda (260px), pode ser recolhido para 70px
   - Mobile: Sidebar oculto por padrão, aparece com overlay ao clicar no botão
   - Topbar fixa no topo (60px de altura)
   - Submenus expansíveis com animação suave
   - Indicador visual do item ativo
   
   =========================== */

/* Variáveis do Sidebar */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 60px;
    --sidebar-bg: #2c3e50;
    --sidebar-hover: #34495e;
    --sidebar-active: #3498db;
    --sidebar-text: #ecf0f1;
    --sidebar-text-muted: #95a5a6;
}

/* Layout principal com sidebar */
body {
    padding-top: 0 !important;
}

/* Top Bar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1040;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.btn-toggle-sidebar {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.3s;
}

.btn-toggle-sidebar:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

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

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

.topbar-user-menu {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 6px;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
}

.topbar-user-menu:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease, left 0.3s ease;
    z-index: 1030;
    display: flex;
    flex-direction: column;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Sidebar collapsed */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-link-text,
.sidebar.collapsed .submenu-arrow {
    display: none;
}

.sidebar.collapsed .sidebar-submenu {
    display: none !important;
}

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

.sidebar-brand {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--sidebar-text);
}

.sidebar-brand i {
    font-size: 1.5rem;
}

/* Sidebar Content */
.sidebar-content {
    flex: 1;
    padding: 15px 0;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin-bottom: 5px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.3s;
    position: relative;
    cursor: pointer;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover);
    color: white;
}

.sidebar-link.active {
    background-color: var(--sidebar-active);
    color: white;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    margin-right: 12px;
    font-size: 1rem;
}

.sidebar-link-text {
    flex: 1;
    white-space: nowrap;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.3s;
}

.sidebar-item.open .submenu-arrow {
    transform: rotate(180deg);
}

/* Submenu */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: rgba(0, 0, 0, 0.2);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-item.open .sidebar-submenu {
    max-height: 500px;
}

.sidebar-submenu li {
    margin: 0;
}

.sidebar-submenu a {
    display: flex;
    align-items: center;
    padding: 10px 20px 10px 52px;
    color: var(--sidebar-text-muted);
    text-decoration: none;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.sidebar-submenu a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
    padding-left: 55px;
}

.sidebar-submenu a i {
    margin-right: 10px;
    width: 16px;
    text-align: center;
    font-size: 0.875rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.sidebar-version {
    color: var(--sidebar-text-muted);
    font-size: 0.75rem;
}

.sidebar-footer-link a {
    color: var(--sidebar-text-muted) !important;
    transition: color 0.3s;
    display: inline-block;
}

.sidebar-footer-link a:hover {
    color: var(--sidebar-text) !important;
}

/* Main Content com Sidebar */
.main-content {
    margin-top: var(--topbar-height) !important;
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: margin-left 0.3s ease;
    min-height: calc(100vh - var(--topbar-height));
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Responsivo - Mobile */
@media (max-width: 991.98px) {
    .topbar-title {
        font-size: 1rem;
    }
    
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    /* Overlay para mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1025;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
}

/* Tablet */
@media (min-width: 992px) and (max-width: 1199.98px) {
    :root {
        --sidebar-width: 220px;
        --sidebar-collapsed-width: 60px;
    }
}

/* Desktop grande */
@media (min-width: 1200px) {
    :root {
        --sidebar-width: 260px;
    }
}

/* Animações suaves */
.sidebar, .main-content, .topbar {
    transition: all 0.3s ease;
}

/* Melhorias visuais */
.sidebar-item.active > .sidebar-link {
    background-color: var(--sidebar-active);
    color: white;
    border-left: 4px solid white;
}

.sidebar-submenu a.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: 600;
}
