/* ===========================
   DARK MODE STYLESHEET
   Ativa quando data-theme="dark"
   =========================== */

[data-theme="dark"] {
    color-scheme: dark;
    --sidebar-bg: #141826;
    --sidebar-text: #e0e0e0;
    --sidebar-hover-bg: #1D1E4E;
    --sidebar-active-bg: #1D1E4E;
    --sidebar-submenu-bg: #000000;
    --cavalinho-red: #ff4d4d;
    --cavalinho-red-hover: #ff6666;
    --page-primary-bg: #040711;
    --page-second-bg: #141826;
    --text-color: #e0e0e0;
    --card-bg: #242424;
    --border-color: #333;
}

/* Fundo e texto geral */
[data-theme="dark"] body {
    background-color: var(--page-primary-bg) !important;
    color: #e0e0e0;
}

[data-theme="dark"] .page-second {
    background-color: transparent !important;
}

    [data-theme="dark"] .page-header-full {
        background-color: var(--page-second-bg) !important;
    }

[data-theme="dark"] #page-content-wrapper {
    background-color: var(--page-primary-bg) !important;
}

/* Fundo e texto geral */
    [data-theme="dark"] footer {
        background-color: var(--page-second-bg);
    }

[data-theme="dark"] body h5 {
    color: #fff;
}

[data-theme="dark"] .page-header-full {
    background-color: #242424;
    border-bottom: 1px solid #333;
}

[data-theme="dark"] .page-header-full h4 {
    color: #e0e0e0;
}

/* Cards */
[data-theme="dark"] .card {
    background-color: #242424;
    border-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .card-header {
    background-color: #2a2a2a;
    border-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .card-body {
    background-color: #242424;
    color: #e0e0e0;
}

/* Input fields */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background-color: #1a1a1a;
    color: #e0e0e0;
    border-color: #444;
}

[data-theme="dark"] input::placeholder {
    color: #999;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    background-color: #242424;
    color: #e0e0e0;
    border-color: #555;
    box-shadow: 0 0 0 0.25rem rgba(255, 99, 132, 0.25);
}

/* Tables */
[data-theme="dark"] .table {
    color: #e0e0e0;
    border-color: #333;
}

[data-theme="dark"] .table thead th {
    background-color: #1B212E;
    color: #9EA3AE;
    border-color: #333;
}

[data-theme="dark"] .table tbody td {
    border-color: #333;
    color: #ffffff;
}

[data-theme="dark"] .table tbody tr {
    background-color: #141826;
}

[data-theme="dark"] .table tbody tr:hover {
    background-color: #1a1d2b;
}

[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
    background-color: #141826;
}

[data-theme="dark"] .table-striped tbody tr:nth-of-type(even) {
    background-color: #1A1E2C;
}

/* DataTable striped rows */
[data-theme="dark"] table.dataTable.table-striped > tbody > tr:nth-of-type(odd) > *,
[data-theme="dark"] table.dataTable.stripe > tbody > tr:nth-child(odd) > * {
    background-color: #141826 !important;
    color: #ffffff !important;
}

[data-theme="dark"] table.dataTable.table-striped > tbody > tr:nth-of-type(even) > *,
[data-theme="dark"] table.dataTable.stripe > tbody > tr:nth-child(even) > * {
    background-color: #1A1E2C !important;
    color: #ffffff !important;
}

/* DataTable hover - invert colors on hover */
[data-theme="dark"] table.dataTable.table-striped > tbody > tr:nth-of-type(odd):hover > *,
[data-theme="dark"] table.dataTable.stripe > tbody > tr:nth-child(odd):hover > * {
    background-color: #1A1E2C !important;
    color: #ffffff !important;
}

[data-theme="dark"] table.dataTable.table-striped > tbody > tr:nth-of-type(even):hover > *,
[data-theme="dark"] table.dataTable.stripe > tbody > tr:nth-child(even):hover > * {
    background-color: #141826 !important;
    color: #ffffff !important;
}

/* DataTable headers */
[data-theme="dark"] table.dataTable > thead > tr > th,
[data-theme="dark"] table.dataTable > thead > tr > td {
    background-color: #1B212E !important;
    color: #9EA3AE !important;
}

/* Buttons */
[data-theme="dark"] .btn-outline-secondary {
    color: #999;
    border-color: #555;
}

[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #333;
    color: #e0e0e0;
}

/* Dropdown/Select */
[data-theme="dark"] .dropdown-menu {
    background-color: #242424;
    border-color: #333;
}

[data-theme="dark"] .dropdown-item {
    color: #e0e0e0;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

/* Alerts */
[data-theme="dark"] .alert {
    background-color: #242424;
    border-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .alert-success {
    background-color: rgba(40, 167, 69, 0.2);
    border-color: #28a745;
    color: #66ff66;
}

[data-theme="dark"] .alert-danger {
    background-color: rgba(220, 53, 69, 0.2);
    border-color: #dc3545;
    color: #ff6b6b;
}

[data-theme="dark"] .alert-warning {
    background-color: rgba(255, 193, 7, 0.2);
    border-color: #ffc107;
    color: #ffeb3b;
}

[data-theme="dark"] .alert-info {
    background-color: rgba(23, 162, 184, 0.2);
    border-color: #17a2b8;
    color: #55ddff;
}

/* DataTable */
[data-theme="dark"] .dataTables_wrapper {
    color: #e0e0e0;
}

[data-theme="dark"] .dataTables_length,
[data-theme="dark"] .dataTables_filter {
    color: #e0e0e0;
}

[data-theme="dark"] .paginate_button {
    color: #e0e0e0 !important;
}

[data-theme="dark"] .paginate_button:hover {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

[data-theme="dark"] .paginate_button.current {
    background-color: #d0080f !important;
    color: #fff !important;
}

/* Modal */
[data-theme="dark"] .modal-content {
    background-color: #242424;
    color: #e0e0e0;
    border-color: #333;
}

[data-theme="dark"] .modal-header {
    border-color: #333;
}

[data-theme="dark"] .modal-footer {
    border-color: #333;
}

[data-theme="dark"] .close {
    color: #e0e0e0;
}

/* Scrollbar personalizado para dark mode */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 10px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #1a1a1a;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 5px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Chart.js dark mode */
[data-theme="dark"] .chart-wrapper canvas {
    filter: invert(0.95) hue-rotate(30deg);
}

/* Links */
[data-theme="dark"] a {
    color: #66b3ff;
}

[data-theme="dark"] a:hover {
    color: #99ccff;
}

/* HR */
[data-theme="dark"] hr {
    border-color: #fff;
}

/* Backgrounds úteis */
[data-theme="dark"] .bg-light {
    background-color: #2a2a2a !important;
}

[data-theme="dark"] .bg-secondary {
    background-color: #333 !important;
}

[data-theme="dark"] .text-muted {
    color: #999 !important;
}

[data-theme="dark"] .text-secondary {
    color: #999 !important;
}

/* Loading spinner */
[data-theme="dark"] .spinner-border {
    color: #ff6347;
}

/* Badge */
[data-theme="dark"] .badge {
    background-color: #333;
    color: #e0e0e0;
}

/* Breadcrumb */
[data-theme="dark"] .breadcrumb {
    background-color: #242424;
}

[data-theme="dark"] .breadcrumb-item.active {
    color: #e0e0e0;
}

[data-theme="dark"] .breadcrumb-item a {
    color: #66b3ff;
}

/* Form labels */
[data-theme="dark"] label {
    color: #e0e0e0;
}

/* Progress bar */
[data-theme="dark"] .progress {
    background-color: #2a2a2a;
}

/* Nav */
[data-theme="dark"] .nav-tabs {
    border-color: #333;
}

[data-theme="dark"] .nav-tabs .nav-link {
    color: #999;
}

[data-theme="dark"] .nav-tabs .nav-link:hover {
    color: #e0e0e0;
    border-color: #444;
}

[data-theme="dark"] .nav-tabs .nav-link.active {
    color: #e0e0e0;
    background-color: #242424;
    border-color: #333 #333 #242424;
}

/* Child Tables (DataTable hierarchy) */
[data-theme="dark"] .dt-child-table-wrapper {
    background-color: #141826 !important;
}

[data-theme="dark"] .dt-child-table-wrapper table {
    background-color: #141826 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .dt-child-table-wrapper table thead {
    background-color: #1B212E !important;
}

[data-theme="dark"] .dt-child-table-wrapper table thead th {
    background-color: #1B212E !important;
    color: #9EA3AE !important;
    border-color: #333 !important;
}

[data-theme="dark"] .dt-child-table-wrapper table tbody td {
    background-color: #141826 !important;
    color: #ffffff !important;
    border-color: #333 !important;
}

[data-theme="dark"] .dt-child-table-wrapper table tbody tr:nth-of-type(odd) > td {
    background-color: #141826 !important;
}

[data-theme="dark"] .dt-child-table-wrapper table tbody tr:nth-of-type(even) > td {
    background-color: #1A1E2C !important;
}

/* Child table hover - invert colors */
[data-theme="dark"] .dt-child-table-wrapper table tbody tr:nth-of-type(odd):hover > td {
    background-color: #1A1E2C !important;
}

[data-theme="dark"] .dt-child-table-wrapper table tbody tr:nth-of-type(even):hover > td {
    background-color: #141826 !important;
}

/* Grand Child Tables (third level hierarchy) */
[data-theme="dark"] .dt-grandchild-table-wrapper {
    background-color: transparent !important;
    color: #ffffff !important;
}

[data-theme="dark"] .dt-grandchild-table-wrapper table {
    background-color: #141826 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .dt-grandchild-table-wrapper table thead th {
    background-color: #1B212E !important;
    color: #9EA3AE !important;
    border-color: #333 !important;
}

[data-theme="dark"] .dt-grandchild-table-wrapper table tbody td {
    background-color: #141826 !important;
    color: #ffffff !important;
    border-color: #333 !important;
}

[data-theme="dark"] .dt-grandchild-table-wrapper table tbody tr:nth-of-type(odd) > td {
    background-color: #141826 !important;
}

[data-theme="dark"] .dt-grandchild-table-wrapper table tbody tr:nth-of-type(even) > td {
    background-color: #1A1E2C !important;
}

/* Grand child table hover */
[data-theme="dark"] .dt-grandchild-table-wrapper table tbody tr:nth-of-type(odd):hover > td {
    background-color: #1A1E2C !important;
}

[data-theme="dark"] .dt-grandchild-table-wrapper table tbody tr:nth-of-type(even):hover > td {
    background-color: #141826 !important;
}
