/* Layout principal */
body {
    font-size: .875rem;
    background-color: #f8f9fa;
}

.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 48px 0 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    background: #2c3e50;
    width: 250px;
}

.sidebar a {
    color: #fff !important;
    padding: .5rem 1rem;
    text-decoration: none;
}

.sidebar a:hover {
    color: #f8f9fa !important;
    background: rgba(255,255,255,.1);
}

.sidebar .nav-item.active a {
    background: rgba(255,255,255,.2);
}

main {
    padding-top: 1.5rem;
}

.navbar-brand {
    padding-top: .75rem;
    padding-bottom: .75rem;
}

.navbar .navbar-toggler {
    top: .25rem;
    right: 1rem;
}

/* Cards */
.card {
    margin-bottom: 1.5rem;
    box-shadow: 0 .15rem 1.75rem 0 rgba(58,59,69,.15)!important;
    border: none;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e3e6f0;
}

/* Tabelas */
.table {
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 2px solid #e3e6f0;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: #4e73df;
    background-color: #f8f9fa;
}

.table td {
    vertical-align: middle;
}

.dt-top {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: nowrap;
}

.dataTables_wrapper .dt-buttons {
    display: inline-flex;
    gap: .5rem;
    flex-wrap: nowrap;
}

.dataTables_wrapper .dt-buttons .btn {
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_length {
    margin-bottom: 0;
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_length label {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_length select {
    width: auto;
    min-width: 56px;
}

/* Botões */
.btn {
    padding: .375rem .75rem;
    font-size: .875rem;
}

.btn-primary {
    background-color: #4e73df;
    border-color: #4e73df;
}

.btn-primary:hover {
    background-color: #2e59d9;
    border-color: #2653d4;
}

/* Responsividade */
@media (max-width: 767.98px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 0;
    }
    
    main {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

@media (max-width: 1200px) {
    .dt-top {
        gap: .4rem;
    }

    .dataTables_wrapper .dataTables_length label {
        font-size: .8rem;
    }

    .dataTables_wrapper .dt-buttons .btn {
        padding: .2rem .45rem;
        font-size: .72rem;
        margin: 0;
    }

    .dataTables_wrapper .dt-buttons .btn.me-2,
    .dataTables_wrapper .dt-buttons .btn.ms-2 {
        margin: 0 !important;
    }

    .dataTables_wrapper .dt-buttons .btn span {
        font-size: 0;
    }

    .dataTables_wrapper .dt-buttons .btn i {
        font-size: .85rem;
    }
}

/* Modal */
.modal-content {
    border: none;
    border-radius: .35rem;
}

.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e3e6f0;
}

.modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #e3e6f0;
}

/* Utilitários */
.shadow {
    box-shadow: 0 .15rem 1.75rem 0 rgba(58,59,69,.15)!important;
}

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

.text-primary {
    color: #4e73df!important;
}

/* Modern Modal Styles - Compact Version */
.modal-modern .modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.modal-modern .modal-header {
    border-bottom: 1px solid #f0f0f0;
    padding: 1rem 1.5rem;
    background: #fff;
    border-radius: 12px 12px 0 0;
}
.modal-modern .modal-title {
    font-weight: 700;
    color: #2c3e50;
    font-size: 1.1rem;
}
.modal-modern .modal-body {
    padding: 1.25rem 1.5rem;
    background: #f8f9fa;
}
.modal-modern .modal-footer {
    border-top: 1px solid #f0f0f0;
    padding: 0.75rem 1.5rem;
    background: #fff;
    border-radius: 0 0 12px 12px;
}

/* Form Fields - Compact with Height Fix */
.form-floating > .form-control,
.form-floating > .form-select {
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    font-size: 0.85rem;
    height: 3.5rem;
    min-height: 3.5rem;
    line-height: 1.25;
}
.form-floating > .form-select {
    padding-top: 1.25rem;
}
.form-floating > label {
    font-size: 0.8rem;
    color: #95a5a6;
    padding: 0.75rem 0.75rem;
}
.form-floating > .form-control:focus,
.form-floating > .form-select:focus {
    border-color: #4e73df;
    box-shadow: 0 0 0 3px rgba(78, 115, 223, 0.1);
}

/* Section Headers - Compact */
.form-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #b0b0b0;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
}
.form-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
    margin-left: 0.75rem;
}
.form-section-title:first-child {
    margin-top: 0;
}

/* Buttons - Compact */
.btn-modern {
    padding: 0.4rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
}

/* Filtros - Botão e Área Compacta */
.btn-filtros {
    font-size: 0.80rem;
    padding: 0.3rem 0.6rem;
}
.filters-compact .form-label {
    font-size: 0.75rem;
    color: #6c757d;
}
.filters-compact .form-select,
.filters-compact .form-control {
    font-size: 0.80rem;
    height: 2.25rem;
    padding: 0.25rem 0.5rem;
}
.filters-compact .input-group-text {
    font-size: 0.80rem;
    padding: 0.25rem 0.5rem;
}
.filters-compact .card-body {
    padding: 0.75rem 1rem;
}

/* Estado ativo do botão de filtros */
.btn-filtros {
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.btn-filtros.btn-outline-primary[aria-expanded="true"] {
    background-color: #6C757D;
    color: #fff;
    border-color: #6C757D;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}
.btn-filtros.btn-outline-primary[aria-expanded="true"] i {
    color: #fff;
}

.btn-filtros.is-open {
    background-color: #6C757D !important;
    color: #fff !important;
    border-color: #6C757D !important;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15) !important;
}
.btn-filtros.is-open i {
    color: #fff !important;
}
.btn-modern-primary {
    background: #4e73df;
    color: white;
    border: none;
}
.btn-modern-primary:hover {
    background: #2e59d9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(78, 115, 223, 0.2);
}
.btn-modern-secondary {
    background: #f1f3f5;
    color: #7f8c8d;
    border: none;
}
.btn-modern-secondary:hover {
    background: #e9ecef;
    color: #2c3e50;
}

/* Green Variation (Success) */
.btn-modern-success {
    background: #1cc88a;
    color: white;
    border: none;
}
.btn-modern-success:hover {
    background: #17a673;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(28, 200, 138, 0.2);
}
.modal-modern-success .form-floating > .form-control:focus,
.modal-modern-success .form-floating > .form-select:focus {
    border-color: #1cc88a;
    box-shadow: 0 0 0 3px rgba(28, 200, 138, 0.1);
}

/* Red Variation (Danger) */
.btn-modern-danger {
    background: #e74a3b;
    color: white;
    border: none;
}
.btn-modern-danger:hover {
    background: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 74, 59, 0.2);
}
.modal-modern-danger .form-floating > .form-control:focus,
.modal-modern-danger .form-floating > .form-select:focus {
    border-color: #e74a3b;
    box-shadow: 0 0 0 3px rgba(231, 74, 59, 0.1);
}

/* Modern Sidebar UI/UX */
.modern-sidebar {
    width: 260px !important;
    height: 100vh !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1000 !important;
    background: linear-gradient(180deg, #4e73df 0%, #224abe 100%) !important;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    padding: 3.5rem 0 1.5rem !important; /* Reduced from 4.5rem to move content up */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Scrollbar para Webkit */
.modern-sidebar::-webkit-scrollbar {
    width: 4px;
}
.modern-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.modern-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Logo Area */
.modern-sidebar .sidebar-brand {
    padding: 0 1.5rem 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.modern-sidebar .sidebar-brand h5 {
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 0.95rem; /* Reduced from 1.1rem to fit toggle button */
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Nav Items */
.modern-sidebar .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    padding: 0.8rem 1rem;
    margin: 0.2rem 0.8rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
}

.modern-sidebar .nav-link i {
    width: 24px;
    text-align: center;
    margin-right: 0.75rem !important;
    font-size: 1.1em;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Hover State */
.modern-sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff !important;
    transform: translateX(5px);
}

.modern-sidebar .nav-link:hover i {
    transform: scale(1.2);
}

/* Active State */
.modern-sidebar .nav-link.active {
    background: #ffffff;
    color: #4e73df !important;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transform: translateX(5px);
}

/* Headers */
.modern-sidebar .nav-header {
    padding: 0 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    opacity: 0.8;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}

/* Collapsed Sidebar */
.modern-sidebar {
    transition: width 0.3s ease;
}

.modern-sidebar.collapsed {
    width: 80px !important;
}

.modern-sidebar.collapsed .sidebar-brand h5,
.modern-sidebar.collapsed .nav-header,
.modern-sidebar.collapsed .btn-outline-light {
    display: none !important;
}

/* Esconder texto dos links mas manter ícone */
.modern-sidebar.collapsed .nav-link {
    font-size: 0;
    justify-content: center;
    padding: 0.8rem 0;
}

.modern-sidebar.collapsed .nav-link i {
    margin-right: 0 !important;
    font-size: 1.4rem; /* Restaurar tamanho do ícone */
}

.modern-sidebar.collapsed .sidebar-brand {
    padding: 0 1rem 1.5rem;
    justify-content: center;
}

.modern-sidebar.collapsed .icon-wrapper {
    margin-right: 0 !important;
}

/* Main Content Adjustment */
main, .main {
    transition: margin-left 0.3s ease;
}

/* Garantir espaço do main ao lado da sidebar */
.modern-sidebar ~ main {
    margin-left: 260px !important;
    width: calc(100% - 260px) !important;
    flex: 0 0 calc(100% - 260px) !important;
    max-width: calc(100% - 260px) !important;
}

/* Se precisar ajustar o main quando sidebar recolhido */
/* O Bootstrap usa classes col, então o ajuste pode ser complexo. 
   Vamos tentar forçar via CSS se a classe expanded for adicionada ao main */
main.expanded, .main.expanded {
    /* Ajuste para quando sidebar é pequena. 
       Assumindo layout padrão do Bootstrap Dashboard */
    margin-left: 80px !important; 
    width: calc(100% - 80px) !important;
    flex: 0 0 calc(100% - 80px) !important;
    max-width: calc(100% - 80px) !important;
}

/* Alternativa quando sidebar recolhida, sem depender de classe no main */
.modern-sidebar.collapsed ~ main {
    margin-left: 80px !important;
    width: calc(100% - 80px) !important;
    flex: 0 0 calc(100% - 80px) !important;
    max-width: calc(100% - 80px) !important;
}

/* Toggle Button */
.sidebar-toggle-btn {
    position: fixed;
    top: 98px; /* Adjusted to sit on the separator line */
    left: 200px; /* Largura sidebar (260) - botão (40) - margem (20) */
    width: 32px; /* Slightly smaller */
    height: 32px; /* Slightly smaller */
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1100;
    backdrop-filter: blur(5px);
    font-size: 0.8rem; /* Smaller icon */
}

.sidebar-toggle-btn:hover {
    background: rgba(255,255,255,0.4);
    transform: scale(1.1);
}

.modern-sidebar.collapsed .sidebar-toggle-btn {
    left: 20px; /* Centralizado na sidebar de 80px (80/2 - 40/2 = 20) */
}

/* --- Receitas Specific Styles (Moved from inline) --- */

/* Custom Column Widths */
.col-descricao {
    width: clamp(220px, 30vw, 420px);
}

.col-descricao .desc-text {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.col-acoes {
    width: 1%;
    white-space: nowrap;
}

.col-acoes .btn {
    padding: 0.25rem 0.5rem;
}

/* Container Limit Helper */
.container-max-width {
    max-width: 1600px;
    margin: 0 auto;
}

/* DataTables Alignment Overrides */
.dt-buttons.btn-group {
    flex-wrap: nowrap !important;
}

div.dataTables_length {
    float: none !important;
    margin-right: 0.5rem;
}

div.dataTables_filter {
    text-align: right;
    float: none !important;
}

@media (max-width: 768px) {
    div.dataTables_wrapper div.dataTables_length,
    div.dataTables_wrapper div.dataTables_filter {
        text-align: left;
    }
    
    div.dataTables_wrapper div.dataTables_paginate {
        justify-content: center !important;
    }
}

@media (max-width: 1400px) {
    .col-descricao {
        width: clamp(200px, 26vw, 360px);
    }
}

/* --- Select2 Customization to match Form Floating height (3.5rem) --- */
.select2-container--bootstrap-5 .select2-selection {
    height: 3.5rem !important;
    min-height: 3.5rem !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 6px !important;
    background-color: #fff;
    padding: 0 !important;
}

/* Adjust text rendering area */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    display: block !important;
    padding-top: 1.25rem !important;
    padding-bottom: 0.25rem !important;
    padding-left: 0.75rem !important;
    font-size: 0.85rem !important;
    color: #212529 !important;
    line-height: 2 !important;
}

/* Adjust arrow position */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 3.5rem !important;
    top: 0 !important;
    right: 0 !important;
    width: 2.5rem !important;
    position: absolute !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow b {
    border-color: #999 transparent transparent transparent;
    border-style: solid;
    border-width: 5px 4px 0 4px;
    height: 0;
    left: 50%;
    margin-left: -4px;
    margin-top: -2px;
    position: absolute;
    top: 50%;
    width: 0;
}

/* Focus states */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: #4e73df !important;
    box-shadow: 0 0 0 3px rgba(78, 115, 223, 0.1) !important;
}

/* Green Focus state for Receitas (Success context) */
.modal-modern-success .select2-container--bootstrap-5.select2-container--focus .select2-selection,
.modal-modern-success .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: #1cc88a !important;
    box-shadow: 0 0 0 3px rgba(28, 200, 138, 0.1) !important;
}
