/* ============================================
   GD3D HOSTING - CUSTOM STYLES
   Modern CSS Framework
   ============================================ */

:root {
    --gd3d-primary: #006699;
    --gd3d-secondary: #FF9900;
    --gd3d-light: #F8F8F8;
    --gd3d-dark: #333333;
    --gd3d-gray: #666666;
    --gd3d-border: #CCCCCC;
    --sidebar-width: 260px;

    /* Light mode colors */
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --bg-sidebar: #f8f9fa;
    --bg-sidebar-header: #F8F8F8;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --hover-bg: #e9ecef;
    --table-hover: rgba(255, 153, 0, 0.1);
}

/* Dark mode colors */
body.dark-mode,
html.dark-mode-preload body {
    --bg-body: #1a1a1a;
    --bg-card: #2d2d2d;
    --bg-sidebar: #242424;
    --bg-sidebar-header: #1f1f1f;
    --text-primary: #e4e4e4;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --hover-bg: #3a3a3a;
    --table-hover: rgba(255, 153, 0, 0.2);
}

/* Pre-load dark mode - prevents flash of light mode */
html.dark-mode-preload {
    background-color: #1a1a1a;
}

html.dark-mode-preload body {
    background-color: #1a1a1a;
    color: #e4e4e4;
}

/* Apply key dark mode styles during preload */
html.dark-mode-preload .navbar,
html.dark-mode-preload .sidebar,
html.dark-mode-preload .main-content,
html.dark-mode-preload .card,
html.dark-mode-preload .page-header {
    background-color: #2d2d2d;
    color: #e4e4e4;
}

html.dark-mode-preload .card-header {
    background-color: #006699 !important;
    color: white !important;
}

html.dark-mode-preload .card-header span,
html.dark-mode-preload .card-header i {
    color: white !important;
}

html.dark-mode-preload .sidebar {
    background-color: #242424 !important;
}

html.dark-mode-preload .list-group-item {
    background-color: transparent;
    color: #e4e4e4;
    border-color: #404040;
}

html.dark-mode-preload .list-group-item.bg-secondary {
    background-color: #495057 !important;
    color: white !important;
}

html.dark-mode-preload .alert-danger {
    background-color: #5a2a2a !important;
    border-color: #8a3a3a !important;
    color: #ffdddd !important;
}

html.dark-mode-preload .alert-danger strong {
    color: #ffdddd !important;
}

html.dark-mode-preload .table,
html.dark-mode-preload table {
    background-color: #1e1e1e !important;
    color: #e4e4e4 !important;
}

html.dark-mode-preload .table thead,
html.dark-mode-preload .table-light {
    background-color: #1f1f1f !important;
    color: #e4e4e4 !important;
}

html.dark-mode-preload .table thead th,
html.dark-mode-preload thead th,
html.dark-mode-preload th {
    background-color: #1f1f1f !important;
    color: #f0f0f0 !important;
    border-color: #3a3a3a !important;
}

html.dark-mode-preload .table th,
html.dark-mode-preload .table td,
html.dark-mode-preload table th,
html.dark-mode-preload table td {
    border-color: #3a3a3a !important;
    color: #e4e4e4 !important;
    background-color: #1e1e1e !important;
}

html.dark-mode-preload .table tbody tr,
html.dark-mode-preload table tbody tr {
    background-color: #1e1e1e !important;
}

html.dark-mode-preload .table tbody td,
html.dark-mode-preload table tbody td {
    background-color: #1e1e1e !important;
    color: #e4e4e4 !important;
}

html.dark-mode-preload .bg-light {
    background-color: #2a2a2a !important;
    color: #e4e4e4 !important;
}

html.dark-mode-preload .bg-warning {
    background-color: #5a4a1a !important;
    color: #ffd43b !important;
}

/* Global Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Enable transitions only when page is ready */
body.dark-mode-ready {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Override Bootstrap primary color */
.bg-primary {
    background-color: var(--gd3d-primary) !important;
}

.btn-primary {
    background-color: var(--gd3d-primary);
    border-color: var(--gd3d-primary);
}

.btn-primary:hover {
    background-color: #004d73;
    border-color: #004d73;
}

.text-primary {
    color: var(--gd3d-primary) !important;
}

/* Secondary color (Orange) */
.btn-secondary {
    background-color: var(--gd3d-secondary);
    border-color: var(--gd3d-secondary);
    color: #000;
}

.btn-secondary:hover {
    background-color: #cc7a00;
    border-color: #cc7a00;
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gd3d-primary) 0%, #0088cc 100%);
}

.login-card {
    max-width: 450px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    overflow: hidden;
}

.login-header {
    background: white;
    padding: 2rem;
    text-align: center;
}

.login-header img {
    max-width: 200px;
    height: auto;
}

.login-body {
    background: white;
    padding: 2rem;
}

.login-footer {
    background: var(--gd3d-light);
    padding: 1.5rem;
    text-align: center;
}

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

/* Main Layout with Sidebar */
.wrapper {
    display: flex;
    width: 100%;
    flex: 1;
    min-height: calc(100vh - 56px);
    /* navbar height */
}

.sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: calc(100vh - 56px);
    transition: all 0.3s;
    overflow-y: auto;
    position: sticky;
    top: 56px;
    background-color: var(--bg-sidebar);
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
    background: var(--bg-sidebar-header);
}

.sidebar-section {
    margin-bottom: 0;
}

.list-group-item {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    transition: all 0.2s;
}

.list-group-item:first-child {
    border-top: 0;
}

.list-group-item:hover {
    background-color: var(--hover-bg);
    padding-left: 1.5rem !important;
}

.list-group-item.bg-secondary {
    background-color: #6c757d !important;
    color: white !important;
}

.list-group-item.bg-secondary:hover {
    background-color: #5a6268 !important;
    padding-left: 1rem !important;
    color: white !important;
}

.list-group-item .fas {
    width: 20px;
    text-align: center;
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 2rem;
    width: 100%;
    min-width: 0;
    /* Fix flexbox overflow */
    background-color: var(--bg-body);
    overflow-x: auto;
}

/* Page Header */
.page-header {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.page-header h1 {
    color: var(--gd3d-primary);
    font-size: 1.8rem;
    margin: 0;
}

.page-header .breadcrumb {
    margin: 0;
    background: transparent;
    padding: 0.5rem 0 0 0;
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.card-header {
    background-color: var(--gd3d-primary);
    color: white;
    border-radius: 10px 10px 0 0 !important;
    padding: 1rem 1.5rem;
    font-weight: 600;
}

/* Forms */
.form-label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-control,
.form-select {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--gd3d-secondary);
    box-shadow: 0 0 0 0.2rem rgba(255, 153, 0, 0.15);
}

/* Buttons */
.btn {
    border-radius: 8px;
    padding: 0.6rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s;
}

.btn i {
    margin-right: 0.5rem;
}

.btn-lg {
    padding: 0.8rem 2rem;
}

/* DataTables Customization */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
}

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

table.dataTable tbody tr:hover {
    background-color: var(--table-hover);
}

/* Custom Table Styles */
.table-modern {
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
}

.table-modern thead {
    background-color: var(--gd3d-primary);
    color: white;
}

.table-modern thead th {
    border: none;
    padding: 1rem;
    font-weight: 600;
}

.table-modern tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

.table-modern tbody tr:hover {
    background-color: var(--table-hover);
}

/* Badges */
.badge {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
}

/* Stats Cards */
.stat-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s;
}

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

.stat-card .stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gd3d-primary);
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Action Buttons */
.action-buttons .btn {
    padding: 0.4rem 0.8rem;
    margin: 0 0.2rem;
}

/* Footer */
.footer {
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 1024px) {

    /* Mini sidebar for tablets and mobile */
    :root {
        --sidebar-mini-width: 65px;
    }

    .sidebar {
        min-width: var(--sidebar-mini-width);
        max-width: var(--sidebar-mini-width);
        position: fixed;
        z-index: 1040;
        background: var(--bg-sidebar);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        transition: all 0.3s ease-in-out;
        overflow-x: hidden;
    }

    /* Expanded sidebar on hover or when has class 'expanded' */
    .sidebar:hover,
    .sidebar.expanded {
        min-width: var(--sidebar-width);
        max-width: var(--sidebar-width);
    }

    /* Sidebar header adjustments */
    .sidebar .sidebar-header {
        cursor: pointer;
    }

    /* Hide text in mini mode, show only icons */
    .sidebar .sidebar-text {
        opacity: 0;
        display: inline-block;
        white-space: nowrap;
        transition: opacity 0.2s;
        width: 0;
        overflow: hidden;
    }

    .sidebar:hover .sidebar-text,
    .sidebar.expanded .sidebar-text {
        opacity: 1;
        width: auto;
        overflow: visible;
    }

    /* Adjust icon spacing */
    .sidebar .list-group-item .fas {
        width: 30px;
        text-align: center;
    }

    /* Hide chevron icons in mini mode */
    .sidebar .float-end {
        opacity: 0;
        transition: opacity 0.2s;
    }

    .sidebar:hover .float-end,
    .sidebar.expanded .float-end {
        opacity: 1;
    }

    /* Adjust list items padding for mini mode */
    .sidebar .list-group-item {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: clip;
    }

    .sidebar:hover .list-group-item,
    .sidebar.expanded .list-group-item {
        overflow: visible;
    }

    /* Prevent collapsed sections from expanding in mini mode */
    .sidebar .collapse:not(.show) {
        display: none;
    }

    .sidebar:hover .collapse.show,
    .sidebar.expanded .collapse.show {
        display: block;
    }

    /* Adjust main content margin */
    .main-content {
        padding: 1rem;
        margin-left: var(--sidebar-mini-width);
        transition: margin-left 0.3s ease-in-out;
    }

    .page-header h1 {
        font-size: 1.4rem;
    }

    /* Add visual indicator that sidebar can be expanded on mobile */
    .sidebar::before {
        content: '\f0c9';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        position: absolute;
        top: 50%;
        right: 5px;
        font-size: 12px;
        color: #999;
        opacity: 0.5;
        pointer-events: none;
    }

    .sidebar:hover::before,
    .sidebar.expanded::before {
        opacity: 0;
    }
}

@media (max-width: 768px) {

    /* Smaller adjustments for phones */
    .main-content {
        padding: 0.5rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    /* Make sure tables are scrollable on small screens */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Unstick top navigation on phones so it scrolls away */
    .navbar.sticky-top {
        position: static !important;
    }
}

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

/* Print Styles */
@media print {

    .sidebar,
    .navbar,
    .footer,
    .btn,
    .action-buttons {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }
}

/* Deuda (Debt) highlighting */
.deuda,
.text-deuda {
    color: #dc3545 !important;
    font-weight: 600;
}

/* Links */
a {
    color: var(--gd3d-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #cc7a00;
    text-decoration: underline;
}

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

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

.sidebar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   Legacy Styles for Old Pages (mensual2026.php, etc)
   ============================================ */

/* Table styles for monthly reports */
.items {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    color: #666666;
}

.rojo {
    color: #cc0000;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
}

.link2 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: bold;
    color: #006699;
}

/* Legacy table styling for old reports */
table.legacy-table {
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
}

table.legacy-table td {
    padding: 8px;
}

table.legacy-table tr:hover {
    background-color: var(--hover-bg);
}

/* ============================================
   DARK MODE ADDITIONAL STYLES
   ============================================ */

/* Dark mode cards */
body.dark-mode .card {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

body.dark-mode .card-body {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* Permitir que las tarjetas .fin-top-card mantengan sus fondos en dark mode */
body.dark-mode .fin-top-card,
body.dark-mode .fin-top-card .card-body {
    background-color: transparent !important;
}

body.dark-mode .card-header {
    border-bottom-color: var(--border-color);
    color: white;
    background-color: var(--gd3d-primary);
}

body.dark-mode .card-header span,
body.dark-mode .card-header i {
    color: white;
}

/* Dark mode table-responsive wrapper */
body.dark-mode .table-responsive {
    background-color: #1e1e1e;
}

/* Dark mode tables */
body.dark-mode .table {
    color: var(--text-primary);
}

body.dark-mode .table,
body.dark-mode table {
    background-color: #1e1e1e;
}

body.dark-mode .table tbody tr,
body.dark-mode table tbody tr {
    background-color: #1e1e1e !important;
}

body.dark-mode .table tbody td,
body.dark-mode table tbody td {
    background-color: #1e1e1e !important;
    color: #e4e4e4 !important;
    border-color: #3a3a3a;
}

body.dark-mode .table thead th,
body.dark-mode table thead th {
    background-color: #1f1f1f !important;
    color: #f0f0f0 !important;
    border-color: #3a3a3a !important;
}

body.dark-mode .table thead,
body.dark-mode table thead {
    background-color: #1f1f1f !important;
}

body.dark-mode thead th {
    background-color: #1f1f1f !important;
    color: #f0f0f0 !important;
    border-color: #3a3a3a !important;
}

body.dark-mode .table-striped tbody tr:nth-of-type(odd),
body.dark-mode .table-striped tbody tr:nth-of-type(odd) td {
    background-color: #252525 !important;
}

body.dark-mode .table-striped tbody tr:nth-of-type(even),
body.dark-mode .table-striped tbody tr:nth-of-type(even) td {
    background-color: #1e1e1e !important;
}

/* Dark mode list group */
body.dark-mode .list-group-item {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.dark-mode .list-group-item.bg-secondary {
    background-color: #495057 !important;
    color: white !important;
}

body.dark-mode .list-group-item.bg-secondary:hover {
    background-color: #5a6268 !important;
    color: white !important;
}

/* Dark mode dropdowns */
body.dark-mode .dropdown-menu {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

body.dark-mode .dropdown-item {
    color: var(--text-primary);
}

body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-item:focus {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

body.dark-mode .dropdown-divider {
    border-color: var(--border-color);
}

/* Dark mode breadcrumbs */
body.dark-mode .breadcrumb-item,
body.dark-mode .breadcrumb-item a {
    color: var(--text-secondary);
}

body.dark-mode .breadcrumb-item.active {
    color: var(--text-primary);
}

/* Dark mode DataTables */
body.dark-mode .dataTables_wrapper .dataTables_length,
body.dark-mode .dataTables_wrapper .dataTables_filter,
body.dark-mode .dataTables_wrapper .dataTables_info,
body.dark-mode .dataTables_wrapper .dataTables_paginate {
    color: var(--text-primary);
}

body.dark-mode .dataTables_wrapper .dataTables_length select,
body.dark-mode .dataTables_wrapper .dataTables_filter input {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Dark mode modals */
body.dark-mode .modal-content {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

body.dark-mode .modal-header {
    border-bottom-color: var(--border-color);
}

body.dark-mode .modal-footer {
    border-top-color: var(--border-color);
}

/* Dark mode scrollbars */
body.dark-mode .sidebar::-webkit-scrollbar-track {
    background: var(--bg-sidebar);
}

body.dark-mode .sidebar::-webkit-scrollbar-thumb {
    background: #555;
}

body.dark-mode .sidebar::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Dark mode button adjustments */
body.dark-mode .btn-outline-secondary {
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.dark-mode .btn-outline-secondary:hover {
    background-color: var(--hover-bg);
    border-color: var(--border-color);
}

/* Dark mode outline buttons */
body.dark-mode .btn-outline-primary {
    color: var(--gd3d-primary);
    border-color: var(--gd3d-primary);
}

body.dark-mode .btn-outline-primary:hover {
    background-color: var(--gd3d-primary);
    color: white;
    border-color: var(--gd3d-primary);
}

body.dark-mode .btn-outline-success {
    color: #28a745;
    border-color: #28a745;
}

body.dark-mode .btn-outline-success:hover {
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}

body.dark-mode .btn-outline-danger {
    color: #dc3545;
    border-color: #dc3545;
}

body.dark-mode .btn-outline-danger:hover {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}

body.dark-mode .btn-outline-warning {
    color: #ffc107;
    border-color: #ffc107;
}

body.dark-mode .btn-outline-warning:hover {
    background-color: #ffc107;
    color: #000;
    border-color: #ffc107;
}

/* Dark mode for table-light class */
body.dark-mode .table-light,
body.dark-mode thead.table-light th,
body.dark-mode tfoot.table-light td {
    background-color: #1f1f1f !important;
    color: #f0f0f0 !important;
    border-color: #3a3a3a !important;
}

body.dark-mode tfoot.table-light {
    border-top: 2px solid #4a4a4a !important;
}

/* Dark mode for bg-light class */
body.dark-mode .bg-light {
    background-color: #2a2a2a !important;
    color: #f0f0f0 !important;
}

body.dark-mode tfoot .bg-light {
    background-color: #252525 !important;
}

body.dark-mode tfoot td {
    background-color: #1f1f1f !important;
    color: #f0f0f0 !important;
}

body.dark-mode tfoot .bg-warning {
    background-color: #5a4a1a !important;
}

/* Dark mode for bg-warning - mejorado para mejor visibilidad */
body.dark-mode .bg-warning {
    background-color: #5a4a1a !important;
    color: #ffd43b !important;
}

body.dark-mode tbody .bg-warning {
    background-color: #4a3a0a !important;
}

body.dark-mode tfoot .bg-warning {
    background-color: #5a4a1a !important;
}

body.dark-mode tfoot .bg-warning strong {
    color: #ff6b6b !important;
    font-size: inherit;
}

body.dark-mode tfoot strong.fs-5,
body.dark-mode tfoot strong.fs-6 {
    color: #ff6b6b !important;
}

body.dark-mode .alert-danger {
    background-color: #5a2a2a !important;
    border-color: #8a3a3a !important;
    color: #ffdddd !important;
}

body.dark-mode .alert-danger strong {
    color: #ffdddd !important;
    font-weight: 700 !important;
}

body.dark-mode .card-body .alert-danger {
    background-color: #5a2a2a !important;
}

body.dark-mode .card-body .alert-danger *,
body.dark-mode .card-body .alert-danger strong {
    color: #ffdddd !important;
}

/* Forzar visibilidad de texto en alertas */
body.dark-mode .alert * {
    color: inherit !important;
}

body.dark-mode .alert-success {
    background-color: #2a4a2a;
    border-color: #3a6a3a;
    color: #ddffdd;
}

body.dark-mode .alert-success strong {
    color: #ddffdd !important;
}

body.dark-mode .alert-warning {
    background-color: #5a4a2a;
    border-color: #8a6a3a;
    color: #fff4dd;
}

body.dark-mode .alert-warning strong {
    color: #fff4dd !important;
}

body.dark-mode .alert-info {
    background-color: #2a3a5a !important;
    border-color: #3a5a8a !important;
    color: #ddeeff !important;
}

body.dark-mode .alert-info strong {
    color: #ddeeff !important;
}

/* Dark mode badges - mejorado para mejor visibilidad */
body.dark-mode .badge.bg-danger {
    background-color: #dc3545 !important;
    color: white !important;
}

body.dark-mode .badge.bg-success {
    background-color: #28a745 !important;
    color: white !important;
}

body.dark-mode .badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

body.dark-mode .badge.bg-info {
    background-color: #17a2b8 !important;
    color: white !important;
}

body.dark-mode .badge.bg-primary {
    background-color: var(--gd3d-primary) !important;
    color: white !important;
}

body.dark-mode .badge.bg-secondary {
    background-color: #6c757d !important;
    color: white !important;
}



/* Dark mode card headers */
body.dark-mode .card-header.bg-danger {
    background-color: #dc3545 !important;
    color: white !important;
}

body.dark-mode .card-header.bg-success {
    background-color: #28a745 !important;
    color: white !important;
}

body.dark-mode .card-header.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

/* Dark mode tables - más específico */
/* Dark mode tables - más específico y oscuro */
body.dark-mode table.table {
    color: var(--text-primary);
    border-color: var(--border-color);
    background-color: #1e1e1e;
}

body.dark-mode table.table th,
body.dark-mode table.table td {
    border-color: #3a3a3a;
    color: #e4e4e4 !important;
    background-color: #1e1e1e;
}

body.dark-mode table.table tbody tr {
    background-color: #1e1e1e !important;
}

body.dark-mode table.table tbody tr:hover {
    background-color: #2a2a2a !important;
}

body.dark-mode table.table tbody td {
    background-color: #1e1e1e !important;
    color: #e4e4e4 !important;
}

/* Dark mode para table hover */
body.dark-mode .table-hover tbody tr:hover,
body.dark-mode .table-hover tbody tr:hover td {
    background-color: #2a2a2a !important;
}

/* Dark mode table borders */
body.dark-mode .table-bordered {
    border-color: var(--border-color);
}

body.dark-mode .table-bordered th,
body.dark-mode .table-bordered td {
    border-color: var(--border-color);
}

/* Dark mode border utilities */
body.dark-mode .border,
body.dark-mode .border-top,
body.dark-mode .border-bottom,
body.dark-mode .border-start,
body.dark-mode .border-end {
    border-color: var(--border-color) !important;
}

/* Dark mode text colors - preserve important colors */
body.dark-mode .text-danger,
html.dark-mode-preload body .text-danger {
    color: #ff6b6b !important;
}

body.dark-mode .text-success,
html.dark-mode-preload body .text-success {
    color: #51cf66 !important;
}

body.dark-mode .text-warning,
html.dark-mode-preload body .text-warning {
    color: #ffd43b !important;
}

body.dark-mode .text-muted,
html.dark-mode-preload body .text-muted {
    color: #adb5bd !important;
}

body.dark-mode .text-dark,
html.dark-mode-preload body .text-dark {
    color: #f8f9fa !important;
}

body.dark-mode small.text-muted,
html.dark-mode-preload body small.text-muted {
    color: #a0a0a0 !important;
}

body.dark-mode .text-primary {
    color: #4dabf7 !important;
}

body.dark-mode table .text-primary,
body.dark-mode .card .text-primary a {
    color: #4dabf7 !important;
}

/* Dark mode for bg-warning in tables */
body.dark-mode .bg-warning {
    background-color: #856404 !important;
    color: #fff3cd !important;
}

body.dark-mode tbody .bg-warning {
    background-color: #664d03 !important;
}

body.dark-mode tfoot .bg-warning {
    background-color: #664d03 !important;
}

/* Dark mode for text in specific contexts */
body.dark-mode strong,
body.dark-mode .fw-bold {
    color: var(--text-primary);
}

body.dark-mode table strong {
    color: #ffffff;
}

body.dark-mode tfoot strong {
    font-weight: 700;
}

/* Asegurar legibilidad en todas las celdas de tabla */
body.dark-mode .table td *,
body.dark-mode table td * {
    color: inherit;
}



/* Dark mode for navbar brand */
body.dark-mode .navbar-brand {
    color: white !important;
}

/* Dark mode pagination */
body.dark-mode .pagination .page-link {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.dark-mode .pagination .page-link:hover {
    background-color: var(--hover-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.dark-mode .pagination .page-item.active .page-link {
    background-color: var(--gd3d-primary);
    border-color: var(--gd3d-primary);
}

/* Dark mode form inputs mejorado */
body.dark-mode input.form-control:focus,
body.dark-mode select.form-select:focus,
body.dark-mode textarea.form-control:focus {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--gd3d-secondary);
}

/* Dark mode for input groups */
body.dark-mode .input-group-text {
    background-color: var(--hover-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Dark mode close buttons */
body.dark-mode .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Dark mode links in tables and cards */
body.dark-mode table a,
body.dark-mode .card a:not(.btn) {
    color: #4dabf7;
}

body.dark-mode table a:hover,
body.dark-mode .card a:not(.btn):hover {
    color: #74c0fc;
}

/* Dark mode thead links */
body.dark-mode thead a {
    color: var(--text-primary) !important;
}

body.dark-mode thead a:hover {
    color: var(--text-secondary) !important;
}

/* Dark mode text-primary in tables */
body.dark-mode table .text-primary,
body.dark-mode .card .text-primary {
    color: #4dabf7 !important;
}

/* Dark mode button improvements */
body.dark-mode .btn-warning {
    background-color: #f59f00;
    border-color: #f59f00;
    color: #000;
}

body.dark-mode .btn-info {
    background-color: #1c7ed6;
    border-color: #1c7ed6;
    color: #fff;
}

body.dark-mode .btn-light {
    background-color: #495057;
    border-color: #495057;
    color: #fff;
}

body.dark-mode .btn-light:hover {
    background-color: #5a6268;
    border-color: #545b62;
    color: #fff;
}

/* Dark mode striped tables */
body.dark-mode .table-striped>tbody>tr:nth-of-type(odd)>* {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Dark mode transition animation - only after page is ready to prevent flash */
body.dark-mode.dark-mode-ready *,
body.dark-mode.dark-mode-ready *:before,
body.dark-mode.dark-mode-ready *:after {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ============================================
   MOBILE BOTTOM NAVIGATION & OFFCANVAS SIDEBAR
   ============================================ */
@media (max-width: 768px) {

    /* Hide sidebar by default acting as an offcanvas overlay */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        transform: translateX(-100%);
        width: 260px !important;
        min-width: 260px !important;
        max-width: 80vw !important;
        height: 100vh !important;
        z-index: 1055 !important;
        background-color: var(--bg-sidebar) !important;
        transition: transform 0.3s ease-in-out !important;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5) !important;
    }

    .sidebar.mobile-show {
        transform: translateX(0) !important;
        display: block !important;
    }

    .sidebar.mobile-show .sidebar-text,
    .sidebar.mobile-show .float-end {
        opacity: 1 !important;
        width: auto !important;
        display: inline-block !important;
        overflow: visible !important;
    }

    .sidebar.mobile-show .list-group-item {
        overflow: visible !important;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    .sidebar.mobile-show .collapse.show {
        display: block !important;
    }

    /* Reduce padding so content is not behind the bottom nav */
    .main-content {
        padding-bottom: 90px;
        margin-left: 0 !important;
    }

    /* Mobile Bottom Navigation Bar */
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 65px;
        background-color: var(--bg-card);
        border-top: 1px solid var(--border-color);
        z-index: 1030;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        padding: 0 10px;
    }

    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        font-size: 0.75rem;
        cursor: pointer;
        transition: color 0.2s;
        text-decoration: none;
        flex: 1;
    }

    .nav-item i {
        font-size: 1.25rem;
        margin-bottom: 3px;
    }

    .nav-item.active,
    .nav-item:hover {
        color: var(--gd3d-primary);
    }

    /* Floating Action Button (FAB) */
    .nav-fab-container {
        position: relative;
        flex: 1;
        display: flex;
        justify-content: center;
    }

    .nav-fab {
        width: 56px;
        height: 56px;
        background: linear-gradient(135deg, #a29bfe, #8c7ae6);
        /* similar to screenshot */
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-size: 1.5rem;
        position: absolute;
        bottom: -28px;
        /* half height to center over the bar */
        box-shadow: 0 4px 15px rgba(140, 122, 230, 0.4);
        cursor: pointer;
        z-index: 1040;
        transition: transform 0.2s, background 0.3s;
    }

    .nav-fab:hover {
        transform: scale(1.05);
    }

    .nav-fab.active {
        transform: rotate(45deg);
        /* turns + into x */
    }

    /* Sidebar Background Overlay */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1054;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-backdrop.show {
        display: block;
        opacity: 1;
    }

    /* Floating Action Menu Overlay */
    .fab-menu-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1035;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .fab-menu-backdrop.show {
        display: block;
        opacity: 1;
    }

    .fab-menu {
        position: fixed;
        bottom: 90px;
        left: 50%;
        transform: translateX(-50%) translateY(20px);
        width: 100%;
        max-width: 350px;
        display: none;
        flex-direction: column;
        align-items: center;
        z-index: 1045;
        opacity: 0;
        transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
        pointer-events: none;
    }

    .fab-menu.show {
        display: flex;
        transform: translateX(-50%) translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .fab-menu-row {
        display: flex;
        gap: 20px;
        margin-bottom: 20px;
        justify-content: center;
    }

    .fab-menu-top-row {
        margin-bottom: 30px;
        gap: 25px;
    }

    .fab-menu-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: white;
        text-align: center;
        width: 80px;
    }

    .fab-menu-btn {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-size: 1.25rem;
        margin-bottom: 8px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    }

    .fab-menu-item span {
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        line-height: 1.2;
    }

    /* Menu colors similar to screenshot */
    .btn-ingreso {
        background: linear-gradient(135deg, #1abc9c, #16a085);
    }

    .btn-gasto {
        background: linear-gradient(135deg, #e74c3c, #c0392b);
        color: white;
        border: 2px solid white;
    }

    .btn-transfer {
        background: linear-gradient(135deg, #8e44ad, #9b59b6);
    }

    .btn-dashboard {
        background: linear-gradient(135deg, #3498db, #2980b9);
    }

    .btn-deuda {
        background: linear-gradient(135deg, #f39c12, #e67e22);
    }
}

@media (min-width: 769px) {

    .mobile-bottom-nav,
    .fab-menu-backdrop,
    .fab-menu {
        display: none !important;
    }
}