/* =============================================
   GESTOR - Tema personalizado (#164194)
   Glassmorphism + cor institucional + dark mode
   ============================================= */

/* ============================================================
   1) OVERRIDE DAS VARIÁVEIS CSS DO HYPER (LIGHT)
   ============================================================ */
:root {
    --ct-primary: #164194;
    --ct-primary-rgb: 22, 65, 148;
}

/* ============================================================
   2) OVERRIDE DAS VARIÁVEIS CSS DO HYPER (DARK)
   O app-saas.css usa html[data-theme=dark] pra setar cinza.
   Precisamos sobrescrever com azul escuro + !important.
   ============================================================ */
html[data-theme=dark],
[data-theme=dark] {
    --ct-body-bg: #0f1b2e !important;
    --ct-body-color: #b8c7db !important;
    --ct-body-bg-rgb: 15, 27, 46 !important;
    --ct-body-color-rgb: 184, 199, 219 !important;
    --ct-card-bg-custom: #152240 !important;
    --ct-dropdown-bg-custom: #182844 !important;
    --ct-input-bg-custom: #1a2d4d !important;
    --ct-box-shadow: 0px 0px 35px 0px rgba(5, 12, 30, 0.5) !important;
    --ct-gray-100: #1a2d4d;
    --ct-gray-200: #152240;
    --ct-gray-300: #1e3558;
    --ct-gray-400: #5a7ba5;
    --ct-gray-500: #8aa4c4;
    --ct-gray-600: #a4b9d2;
    --ct-gray-700: #c0d0e3;
    --ct-gray-800: #d6e2f0;
    --ct-gray-900: #e8eef6;
    --ct-light: #1e3558;
    --ct-dark: #e8eef6;
    --ct-light-rgb: 30, 53, 88;
    --ct-dark-rgb: 232, 238, 246;
}

/* Sidebar — manter azul institucional em AMBOS os modos */
html[data-menu-color=dark] {
    --ct-menu-bg: linear-gradient(180deg, rgba(22,65,148,0.92) 0%, rgba(13,42,99,0.96) 100%) !important;
    --ct-menu-item-color: #c8d6f0 !important;
    --ct-menu-item-hover-color: #ffffff !important;
    --ct-menu-item-active-color: #ffffff !important;
}
/* Dark mode — sidebar azul mais profundo */
html[data-theme=dark][data-menu-color=light],
html[data-theme=dark][data-menu-color=dark] {
    --ct-menu-bg: linear-gradient(180deg, rgba(10,30,78,0.97) 0%, rgba(6,18,52,0.99) 100%) !important;
    --ct-menu-item-color: #8aa4c4 !important;
    --ct-menu-item-hover-color: #e0eaff !important;
    --ct-menu-item-active-color: #ffffff !important;
    --ct-help-box-bg: rgba(22,65,148,0.25) !important;
}

/* Topbar — manter consistente no dark mode */
html[data-topbar-color=light] {
    --ct-topbar-bg: #ffffff;
    --ct-topbar-item-color: #6c757d;
    --ct-topbar-item-hover-color: #164194;
}
html[data-theme=dark][data-topbar-color=light],
html[data-theme=dark][data-topbar-color=dark] {
    --ct-topbar-bg: #12203a !important;
    --ct-topbar-item-color: #8aa4c4 !important;
    --ct-topbar-item-hover-color: #c0d8ff !important;
    --ct-topbar-search-bg: #1a2d4d !important;
    --ct-topbar-user-bg: #162647 !important;
    --ct-topbar-user-border: #1e3558 !important;
}

/* --- Fonte moderna --- */
body {
    font-family: 'Inter', 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0.01em;
}

/* ============================================================
   3) SIDEBAR
   ============================================================ */
.leftside-menu {
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-right: 1px solid rgba(255,255,255,0.08) !important;
}

.leftside-menu .logo .logo-lg img,
.logo-topbar .logo-lg img {
    height: 88px;
}

.side-nav .side-nav-link:hover {
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
    margin: 0 8px;
    padding-left: calc(var(--ct-menu-item-padding-x) - 8px);
}
.side-nav .side-nav-link.active,
.side-nav .side-nav-item.menuitem-active > .side-nav-link {
    background: rgba(255,255,255,0.12);
    border-radius: 8px;
    margin: 0 8px;
    padding-left: calc(var(--ct-menu-item-padding-x) - 8px);
}
.side-nav .side-nav-title {
    color: rgba(255,255,255,0.45);
    font-size: 0.7rem;
    letter-spacing: 1px;
}

/* ============================================================
   4) TOPBAR — glassmorphism
   ============================================================ */
.navbar-custom {
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    background: rgba(255,255,255,0.78) !important;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
html[data-theme=dark] .navbar-custom {
    background: rgba(18,32,58,0.88) !important;
    border-bottom: 1px solid rgba(100,160,255,0.08);
}

/* ============================================================
   5) CONTENT AREA — fundo com leve tom azul no dark mode
   ============================================================ */
.content-page {
    transition: background 0.3s ease;
}
html[data-theme=dark] .content-page {
    background-color: #0f1b2e !important;
}

/* ============================================================
   6) CARDS — glassmorphism
   ============================================================ */
.card {
    border-radius: 14px;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 2px 16px rgba(22,65,148,0.04), 0 1px 3px rgba(0,0,0,0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
}
.card:hover {
    box-shadow: 0 6px 24px rgba(22,65,148,0.08), 0 2px 6px rgba(0,0,0,0.04);
}

html[data-theme=dark] .card {
    background-color: #152240 !important;
    border: 1px solid rgba(100,160,255,0.08);
    box-shadow: 0 2px 16px rgba(0,0,0,0.2), 0 1px 3px rgba(0,0,0,0.15);
}
html[data-theme=dark] .card:hover {
    border-color: rgba(100,160,255,0.14);
    box-shadow: 0 6px 24px rgba(0,0,0,0.25), 0 2px 6px rgba(22,65,148,0.1);
}

.card-header {
    border-bottom: 1px solid rgba(0,0,0,0.05);
    background: transparent;
}
html[data-theme=dark] .card-header {
    border-bottom: 1px solid rgba(100,160,255,0.08);
    background: transparent;
}

.card-body {
    background: transparent;
}

/* ============================================================
   7) TABELAS
   ============================================================ */
.table {
    border-radius: 10px;
    overflow: hidden;
}
/* Thead padrão (sem table-dark) */
.table thead:not(.table-dark) th {
    background: rgba(22,65,148,0.06) !important;
    color: #164194 !important;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(22,65,148,0.12);
    padding: 12px 16px;
}
/* Thead com table-dark: usar azul institucional em vez de cinza */
.table .table-dark th,
.table .table-dark td,
thead.table-dark th,
thead.table-dark td,
.table-dark > tr > th,
.table-dark > tr > td {
    background-color: #164194 !important;
    color: #fff !important;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(22,65,148,0.8) !important;
    padding: 12px 16px;
}

/* Dark mode: thead padrão */
html[data-theme=dark] .table thead:not(.table-dark) th {
    background: rgba(22,65,148,0.25) !important;
    background-color: rgba(22,65,148,0.25) !important;
    color: #a8c8f0 !important;
    border-bottom: 2px solid rgba(100,160,255,0.15);
}
/* Dark mode: thead table-dark */
html[data-theme=dark] .table .table-dark th,
html[data-theme=dark] .table .table-dark td,
html[data-theme=dark] thead.table-dark th,
html[data-theme=dark] thead.table-dark td,
html[data-theme=dark] .table-dark > tr > th,
html[data-theme=dark] .table-dark > tr > td {
    background-color: rgba(22,65,148,0.35) !important;
    color: #a8c8f0 !important;
    border-bottom: 2px solid rgba(100,160,255,0.15) !important;
}

.table tbody tr {
    transition: background 0.2s ease;
}
.table tbody tr:hover {
    background: rgba(22,65,148,0.03);
}
html[data-theme=dark] .table tbody tr:hover {
    background: rgba(100,160,255,0.05) !important;
    background-color: rgba(100,160,255,0.05) !important;
}
html[data-theme=dark] .table {
    color: #b8c7db !important;
}
html[data-theme=dark] .table td,
html[data-theme=dark] .table th:not(.table-dark th) {
    border-color: rgba(100,160,255,0.08) !important;
    color: #b8c7db !important;
}
html[data-theme=dark] .table > :not(caption) > * > * {
    background-color: transparent !important;
    color: #b8c7db !important;
}
html[data-theme=dark] .table thead:not(.table-dark) > tr > * {
    background-color: rgba(22,65,148,0.25) !important;
    color: #a8c8f0 !important;
}
html[data-theme=dark] .table tbody > tr > * {
    background-color: var(--ct-card-bg-custom) !important;
}
.table td {
    padding: 10px 16px;
    vertical-align: middle;
}

/* DataTables */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #164194 !important;
    color: #fff !important;
    border-color: #164194 !important;
    border-radius: 8px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: rgba(22,65,148,0.1) !important;
    color: #164194 !important;
    border-color: rgba(22,65,148,0.2) !important;
}
html[data-theme=dark] .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #8aa4c4 !important;
}
html[data-theme=dark] .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: rgba(22,65,148,0.3) !important;
    color: #c0d8ff !important;
    border-color: rgba(22,65,148,0.4) !important;
}
html[data-theme=dark] .dataTables_wrapper .dataTables_info,
html[data-theme=dark] .dataTables_wrapper .dataTables_length label,
html[data-theme=dark] .dataTables_wrapper .dataTables_filter label {
    color: #8aa4c4;
}

/* ============================================================
   8) BOTÕES
   ============================================================ */
.btn {
    border-radius: 8px;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: all 0.25s ease;
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: #164194;
    border-color: #164194;
}
.btn-primary:hover {
    background: #1a4faf;
    border-color: #1a4faf;
}
html[data-theme=dark] .btn-primary {
    background: #1e52b0;
    border-color: #1e52b0;
}
html[data-theme=dark] .btn-primary:hover {
    background: #2662cc;
    border-color: #2662cc;
}

.btn-outline-primary {
    color: #164194;
    border-color: #164194;
}
.btn-outline-primary:hover {
    background: #164194;
    border-color: #164194;
}
html[data-theme=dark] .btn-outline-primary {
    color: #6da0e8;
    border-color: #3a6cc0;
}
html[data-theme=dark] .btn-outline-primary:hover {
    background: #1e52b0;
    border-color: #1e52b0;
    color: #fff;
}

html[data-theme=dark] .btn-light {
    background: #1a2d4d;
    border-color: #1e3558;
    color: #b8c7db;
}
html[data-theme=dark] .btn-light:hover {
    background: #1e3558;
    border-color: #254069;
    color: #d6e2f0;
}

/* ============================================================
   9) FORMULÁRIOS
   ============================================================ */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    padding: 8px 14px;
    transition: all 0.2s ease;
}
.form-control:focus, .form-select:focus {
    border-color: #164194;
    box-shadow: 0 0 0 3px rgba(22,65,148,0.12);
}
html[data-theme=dark] .form-control,
html[data-theme=dark] .form-select {
    background-color: #1a2d4d !important;
    border: 1px solid rgba(100,160,255,0.12);
    color: #b8c7db !important;
}
html[data-theme=dark] .form-control:focus,
html[data-theme=dark] .form-select:focus {
    border-color: #3a6cc0;
    box-shadow: 0 0 0 3px rgba(22,65,148,0.25);
    background-color: #1e3558 !important;
}
html[data-theme=dark] .form-control::placeholder {
    color: #5a7ba5;
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: #495057;
    margin-bottom: 6px;
}
html[data-theme=dark] .form-label {
    color: #8aa4c4;
}

html[data-theme=dark] .input-group-text {
    background-color: #152240;
    border-color: rgba(100,160,255,0.12);
    color: #8aa4c4;
}

/* ============================================================
   10) BADGES
   ============================================================ */
.badge {
    border-radius: 6px;
    font-weight: 500;
    letter-spacing: 0.3px;
    padding: 5px 10px;
}

/* ============================================================
   11) MODAIS
   ============================================================ */
.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
html[data-theme=dark] .modal-content {
    background-color: #152240 !important;
    border: 1px solid rgba(100,160,255,0.1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-header {
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 16px 24px;
}
.modal-footer {
    border-top: 1px solid rgba(0,0,0,0.06);
    padding: 16px 24px;
}
html[data-theme=dark] .modal-header {
    border-bottom: 1px solid rgba(100,160,255,0.1);
}
html[data-theme=dark] .modal-footer {
    border-top: 1px solid rgba(100,160,255,0.1);
}
html[data-theme=dark] .modal-title {
    color: #d6e2f0;
}
html[data-theme=dark] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ============================================================
   12) DROPDOWNS
   ============================================================ */
.dropdown-menu {
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 8px;
}
html[data-theme=dark] .dropdown-menu {
    background-color: #182844 !important;
    border: 1px solid rgba(100,160,255,0.1);
    box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.dropdown-item {
    border-radius: 8px;
    padding: 8px 14px;
    transition: all 0.15s ease;
}
.dropdown-item:hover {
    background: rgba(22,65,148,0.06);
}
html[data-theme=dark] .dropdown-item {
    color: #b8c7db;
}
html[data-theme=dark] .dropdown-item:hover {
    background: rgba(22,65,148,0.2);
    color: #e0eaff;
}
html[data-theme=dark] .dropdown-divider {
    border-color: rgba(100,160,255,0.08);
}

/* ============================================================
   13) BREADCRUMB / PAGE TITLE
   ============================================================ */
.breadcrumb {
    background: transparent;
    font-size: 0.85rem;
}
html[data-theme=dark] .breadcrumb-item,
html[data-theme=dark] .breadcrumb-item a {
    color: #6da0e8;
}
html[data-theme=dark] .breadcrumb-item.active {
    color: #8aa4c4;
}
.page-title {
    font-weight: 700;
    color: #1a1f36;
    letter-spacing: -0.01em;
}
html[data-theme=dark] .page-title {
    color: #e0eaff;
}
html[data-theme=dark] .page-title-box {
    border-bottom-color: rgba(100,160,255,0.06) !important;
}

/* ============================================================
   14) ALERTS
   ============================================================ */
.alert {
    border-radius: 10px;
    border: none;
}

/* ============================================================
   15) SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(22,65,148,0.15);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(22,65,148,0.3);
}
html[data-theme=dark] ::-webkit-scrollbar-thumb {
    background: rgba(100,160,255,0.15);
}
html[data-theme=dark] ::-webkit-scrollbar-thumb:hover {
    background: rgba(100,160,255,0.25);
}

/* ============================================================
   16) LINKS
   ============================================================ */
a {
    color: #164194;
    transition: color 0.2s ease;
}
a:hover {
    color: #1a4faf;
}
html[data-theme=dark] a {
    color: #6da0e8;
}
html[data-theme=dark] a:hover {
    color: #8cb4f0;
}

/* ============================================================
   17) FOOTER
   ============================================================ */
.footer {
    border-top: 1px solid rgba(0,0,0,0.05);
    font-size: 0.85rem;
}
html[data-theme=dark] .footer {
    border-top: 1px solid rgba(100,160,255,0.06);
    color: #5a7ba5;
}

/* ============================================================
   18) LOGO — forçar visibilidade em todos os modos
   ============================================================ */
/* A logo do FIEMA é branca, funciona em fundo escuro.
   Forçar logo-light sempre visível pois é a que tem a imagem. */
html[data-theme=dark] .logo-topbar .logo-light,
html[data-menu-color=dark] .logo.logo-light,
html[data-theme=dark] .logo.logo-light {
    display: block !important;
}
html[data-theme=dark] .logo-topbar .logo-dark,
html[data-theme=dark] .logo.logo-dark {
    display: none !important;
}

/* ============================================================
   19) DARK MODE TOGGLE
   ============================================================ */
#light-dark-mode {
    cursor: pointer;
    transition: all 0.3s ease;
}
#light-dark-mode:hover {
    opacity: 0.7;
}

/* ============================================================
   20) TEXTO / TIPOGRAFIA DARK MODE
   ============================================================ */
html[data-theme=dark] h1, html[data-theme=dark] h2,
html[data-theme=dark] h3, html[data-theme=dark] h4,
html[data-theme=dark] h5, html[data-theme=dark] h6,
html[data-theme=dark] .h1, html[data-theme=dark] .h2,
html[data-theme=dark] .h3, html[data-theme=dark] .h4,
html[data-theme=dark] .h5, html[data-theme=dark] .h6 {
    color: #d6e2f0;
}
html[data-theme=dark] p,
html[data-theme=dark] span,
html[data-theme=dark] label,
html[data-theme=dark] td,
html[data-theme=dark] li {
    color: #b8c7db;
}
html[data-theme=dark] .text-muted {
    color: #5a7ba5 !important;
}
html[data-theme=dark] .text-dark {
    color: #d6e2f0 !important;
}

/* ============================================================
   21) COMPONENTES AUXILIARES DARK MODE
   ============================================================ */
/* List group */
html[data-theme=dark] .list-group-item {
    background-color: #152240;
    border-color: rgba(100,160,255,0.08);
    color: #b8c7db;
}
html[data-theme=dark] .list-group-item:hover {
    background-color: #1a2d4d;
}

/* Accordion */
html[data-theme=dark] .accordion-item {
    background-color: #152240;
    border-color: rgba(100,160,255,0.08);
}
html[data-theme=dark] .accordion-button {
    background-color: #152240;
    color: #b8c7db;
}
html[data-theme=dark] .accordion-button:not(.collapsed) {
    background-color: rgba(22,65,148,0.2);
    color: #6da0e8;
}

/* Popover */
html[data-theme=dark] .popover {
    background-color: #182844;
    border-color: rgba(100,160,255,0.1);
}
html[data-theme=dark] .popover-header {
    background-color: #1a2d4d;
    border-color: rgba(100,160,255,0.08);
    color: #d6e2f0;
}
html[data-theme=dark] .popover-body {
    color: #b8c7db;
}

/* Toast */
html[data-theme=dark] .toast {
    background-color: #182844;
    border-color: rgba(100,160,255,0.1);
    color: #b8c7db;
}

/* Widget/stat cards */
html[data-theme=dark] .widget-icon {
    opacity: 0.9;
}

/* Select2 (se usar) */
html[data-theme=dark] .select2-container--default .select2-selection--single,
html[data-theme=dark] .select2-container--default .select2-selection--multiple {
    background-color: #1a2d4d;
    border-color: rgba(100,160,255,0.12);
    color: #b8c7db;
}
html[data-theme=dark] .select2-container--default .select2-results__option {
    background-color: #182844;
    color: #b8c7db;
}
html[data-theme=dark] .select2-container--default .select2-results__option--highlighted {
    background-color: rgba(22,65,148,0.3);
    color: #e0eaff;
}
html[data-theme=dark] .select2-dropdown {
    background-color: #182844;
    border-color: rgba(100,160,255,0.12);
}

/* ============================================================
   22) SELECTION
   ============================================================ */
::selection {
    background: rgba(22,65,148,0.15);
    color: inherit;
}
html[data-theme=dark] ::selection {
    background: rgba(100,160,255,0.2);
}

/* ============================================================
   23) TOOLTIP
   ============================================================ */
.tooltip-inner {
    border-radius: 6px;
    font-size: 0.8rem;
}

/* ============================================================
   24) PROGRESS BAR
   ============================================================ */
.progress {
    border-radius: 8px;
    height: 6px;
}
html[data-theme=dark] .progress {
    background-color: #1a2d4d;
}
.progress-bar {
    background: linear-gradient(90deg, #164194 0%, #4a7cda 100%);
}

/* ============================================================
   25) NAV TABS / PILLS
   ============================================================ */
.nav-tabs .nav-link.active {
    border-color: #164194;
    color: #164194;
    font-weight: 600;
}
html[data-theme=dark] .nav-tabs .nav-link.active {
    background-color: #152240;
    border-color: #3a6cc0;
    color: #6da0e8;
}
html[data-theme=dark] .nav-tabs .nav-link {
    color: #8aa4c4;
}
html[data-theme=dark] .nav-tabs .nav-link:hover {
    border-color: rgba(100,160,255,0.15);
    color: #c0d8ff;
}
.nav-pills .nav-link.active {
    background: #164194;
    border-radius: 8px;
}
html[data-theme=dark] .nav-pills .nav-link.active {
    background: #1e52b0;
}

/* ============================================================
   26) BORDAS E SEPARADORES DARK MODE
   ============================================================ */
html[data-theme=dark] hr {
    border-color: rgba(100,160,255,0.08);
}
html[data-theme=dark] .border {
    border-color: rgba(100,160,255,0.1) !important;
}
html[data-theme=dark] .border-bottom {
    border-bottom-color: rgba(100,160,255,0.08) !important;
}
html[data-theme=dark] .border-top {
    border-top-color: rgba(100,160,255,0.08) !important;
}

/* ============================================================
   27) ANIMAÇÃO SUAVE GERAL
   ============================================================ */
.content-page,
.card,
.btn,
.form-control,
.table,
.dropdown-menu,
.modal-content,
.navbar-custom,
.leftside-menu {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}
