/* ============================================
   GTI IoT - Layout Base
   Cores Empresariais + Design Moderno
============================================ */

:root {
    /* Cores Primárias */
    --gti-primary: #475569;        /* Cinza slate */
    --gti-primary-dark: #334155;
    --gti-primary-light: #64748b;
    
    /* Cores Secundárias */
    --gti-secondary: #64748b;      /* Cinza moderno */
    --gti-blue: #0369a1;           /* Azul GTI institucional */
    --gti-blue-dark: #075985;
    --gti-success: #10b981;
    --gti-warning: #f59e0b;
    --gti-danger: #ef4444;
    --gti-info: #06b6d4;
    
    /* Cores de Fundo */
    --gti-bg-body: #f1f5f9;
    --gti-bg-sidebar: #0e3753;     /* Azul escuro personalizado */
    --gti-bg-sidebar-hover: #125c87;
    --gti-bg-header: #ffffff;
    --gti-bg-card: #ffffff;
    
    /* Texto */
    --gti-text-primary: #1e293b;
    --gti-text-secondary: #64748b;
    --gti-text-light: #94a3b8;
    --gti-text-sidebar: #cbd5e1;
    
    /* Bordas */
    --gti-border-color: #e2e8f0;
    
    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    
    /* Header */
    --header-height: 64px;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Dark Mode Theme
============================================ */

body[data-theme="dark"] {
    /* Cores Primárias Dark */
    --gti-primary: #64748b;
    --gti-primary-dark: #475569;
    --gti-primary-light: #94a3b8;
    
    /* Cores de Fundo Dark */
    --gti-bg-body: #0f172a;
    --gti-bg-sidebar: #1e293b;
    --gti-bg-sidebar-hover: #334155;
    --gti-bg-header: #1e293b;
    --gti-bg-card: #1e293b;
    
    /* Texto Dark */
    --gti-text-primary: #f1f5f9;
    --gti-text-secondary: #cbd5e1;
    --gti-text-light: #94a3b8;
    --gti-text-sidebar: #e2e8f0;
    
    /* Bordas Dark */
    --gti-border-color: #334155;
    
    /* Sombras Dark */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    
    /* Bootstrap overrides para dark mode */
    --bs-body-color: #f1f5f9;
    --bs-dropdown-color: #f1f5f9;
    --bs-dropdown-bg: #1e293b;
    --bs-dropdown-border-color: #334155;
    --bs-dropdown-link-color: #f1f5f9;
    --bs-dropdown-link-hover-color: #f1f5f9;
    --bs-dropdown-link-hover-bg: #334155;
}

body[data-theme="dark"] .header {
    background: linear-gradient(to bottom, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid #334155;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   Reset e Base
============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--gti-text-primary);
    background-color: var(--gti-bg-body);
    overflow-x: hidden;
    min-height: 100%;
}

/* ============================================
   Layout Principal
============================================ */

.wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    min-width: 0; /* Previne overflow */
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

.page-content {
    flex: 1;
    padding: 2rem 1.5rem;
    margin-top: var(--header-height);
    width: 100%;
}

/* ============================================
   Sidebar
============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--gti-bg-sidebar);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed span {
    display: none;
}

.sidebar.collapsed .sidebar-footer {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .sidebar-logo {
    max-width: 50px;
    max-height: 50px;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.2s ease;
}

.sidebar-header:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-logo {
    max-width: 140px;
    max-height: 44px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

/* Scrollbar customizada */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #ffffff;
    margin-top: 0.5rem;
    opacity: 0.7;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--gti-text-sidebar);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item i {
    font-size: 1.125rem;
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    background-color: var(--gti-bg-sidebar-hover);
    color: #ffffff;
    transform: translateX(2px);
}

.nav-item.active {
    background-color: #0a2436;
    color: #ffffff;
    border-left: 4px solid #38bdf8;
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #38bdf8;
}

/* Submenu */
.submenu {
    background-color: rgba(0, 0, 0, 0.2);
}

.submenu-item {
    padding-left: 3.5rem !important;
    font-size: 0.875rem;
}

.submenu-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.nav-item[aria-expanded="true"] .submenu-arrow {
    transform: rotate(180deg);
}

/* Badge */
.nav-item .badge {
    margin-left: auto;
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s ease;
    color: #ffffff;
}

.version-text {
    color: #ffffff;
    font-size: 0.75rem;
}

.sidebar-footer-content {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* ============================================
   Header
============================================ */

.header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: linear-gradient(to bottom, #f0f9ff 0%, #ffffff 100%);
    border-bottom: 1px solid #e0f2fe;
    box-shadow: 0 4px 12px rgba(3, 105, 161, 0.08), 0 2px 4px rgba(0, 0, 0, 0.06);
    z-index: 999;
    transition: left 0.3s ease;
}

.sidebar.collapsed ~ .main-content .header {
    left: var(--sidebar-collapsed-width);
}

.header-container {
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gti-text-primary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 0.375rem;
}

.sidebar-toggle:hover {
    background-color: var(--gti-bg-body);
    color: var(--gti-primary);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
}

.header-logo {
    font-size: 1.5rem;
    color: var(--gti-primary);
}

.header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gti-text-primary);
}

/* Tenant Info */
.tenant-info {
    display: flex;
    align-items: center;
}

.tenant-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 1px solid var(--gti-border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    height: 42px;
    min-height: 42px;
}

.tenant-badge:hover {
    background-color: var(--gti-bg-body);
    border-color: var(--gti-primary-light);
}

.system-name {
    font-weight: 600;
    color: var(--gti-text-primary);
}

.separator {
    color: var(--gti-border-color);
    margin: 0 0.25rem;
}

.tenant-name {
    font-weight: 500;
    color: var(--gti-text-primary);
    line-height: 1.5;
}

.tenant-subdomain {
    font-size: 0.75rem;
}

/* User Menu */
.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 1px solid var(--gti-border-color);
    border-radius: 0.5rem;
    color: var(--gti-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
    height: 42px;
    min-height: 42px;
}

.user-menu-toggle:hover {
    background-color: var(--gti-bg-body);
    border-color: var(--gti-primary-light);
}

.user-menu-toggle i {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dropdown do user menu com mesma largura do botão */
.user-menu {
    position: relative;
}

.user-menu-toggle + .dropdown-menu {
    min-width: 100%;
    width: max-content;
    max-width: 350px;
}

.dropdown-header .user-info-detail {
    padding: 0.25rem 0;
}

/* ============================================
   Overlay para Mobile
============================================ */

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    display: block;
}

/* ============================================
   Messages/Alerts
============================================ */

.messages-container {
    margin-bottom: 1.5rem;
}

.alert {
    border-radius: 0.5rem;
    border-left: 4px solid;
}

.alert-success {
    border-left-color: var(--gti-success);
}

.alert-warning {
    border-left-color: var(--gti-warning);
}

.alert-danger {
    border-left-color: var(--gti-danger);
}

.alert-info {
    border-left-color: var(--gti-info);
}

/* ============================================
   Responsividade
============================================ */

/* Tablets */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .header {
        left: 0;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .tenant-name,
    .user-name {
        display: none;
    }
}

/* Mobile */
@media (max-width: 575px) {
    .page-content {
        padding: 1rem;
    }
    
    .header-container {
        padding: 0 1rem;
    }
    
    .tenant-badge {
        padding: 0.5rem;
    }
    
    .tenant-subdomain {
        display: none;
    }
    
    .user-menu-toggle {
        padding: 0.5rem;
        border: none;
    }
}

/* ============================================
   Utilitários
============================================ */

.card {
    background-color: var(--gti-bg-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gti-border-color);
}

.btn-primary {
    background-color: var(--gti-primary);
    border-color: var(--gti-primary);
}

.btn-primary:hover {
    background-color: var(--gti-primary-dark);
    border-color: var(--gti-primary-dark);
}

/* Botão azul institucional GTI - máxima especificidade */
button[data-bs-toggle="modal"][data-bs-target="#importModal"],
button[data-bs-toggle="modal"].btn-gti-blue,
#import-btn.btn.btn-gti-blue,
.btn.btn-gti-blue,
button.btn-gti-blue,
button[data-bs-target="#importModal"] {
    background-color: #0369a1 !important;
    border-color: #0369a1 !important;
    color: #ffffff !important;
}

button[data-bs-toggle="modal"][data-bs-target="#importModal"]:hover,
button[data-bs-toggle="modal"][data-bs-target="#importModal"]:focus,
button[data-bs-toggle="modal"][data-bs-target="#importModal"]:active,
button[data-bs-toggle="modal"].btn-gti-blue:hover,
button[data-bs-toggle="modal"].btn-gti-blue:focus,
button[data-bs-toggle="modal"].btn-gti-blue:active,
#import-btn.btn.btn-gti-blue:hover,
#import-btn.btn.btn-gti-blue:focus,
#import-btn.btn.btn-gti-blue:active,
.btn.btn-gti-blue:hover,
.btn.btn-gti-blue:focus,
.btn.btn-gti-blue:active,
button.btn-gti-blue:hover,
button.btn-gti-blue:focus, 
button.btn-gti-blue:active {
    background-color: #075985 !important;
    border-color: #075985 !important;
    color: #ffffff !important;
}

.btn-info {
    background-color: var(--gti-blue) !important;
    border-color: var(--gti-blue) !important;
    color: #ffffff !important;
}

.btn-info:hover {
    background-color: var(--gti-blue-dark) !important;
    border-color: var(--gti-blue-dark) !important;
    color: #ffffff !important;
}

/* Checkboxes customizados com azul GTI */
.form-check-input {
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid #cbd5e1;
    border-radius: 0.25rem;
    cursor: pointer;
}

.form-check-input:hover {
    border-color: var(--gti-blue);
}

.form-check-input:checked {
    background-color: var(--gti-blue) !important;
    border-color: var(--gti-blue) !important;
}

.form-check-input:focus {
    border-color: var(--gti-blue);
    box-shadow: 0 0 0 0.2rem rgba(3, 105, 161, 0.25);
}

/* Ocultar completamente campos de logo base64 e seus wrappers do Crispy Forms */
.logo-base64-hidden,
input[type="hidden"][name*="logo"],
input[name="main_logo"],
input[name="dark_logo"],
#div_id_main_logo,
#div_id_dark_logo {
    display: none !important;
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    position: absolute !important;
    width: 0 !important;
}

/* Se o Crispy Forms renderizar como textarea */
textarea[name="main_logo"],
textarea[name="dark_logo"] {
    display: none !important;
}

.text-primary {
    color: var(--gti-primary) !important;
}

.bg-primary {
    background-color: var(--gti-primary) !important;
}

/* Paginação - cores neutras */
.pagination {
    --bs-pagination-color: var(--gti-text-primary);
    --bs-pagination-hover-color: var(--gti-text-primary);
    --bs-pagination-active-bg: #e2e8f0;
    --bs-pagination-active-border-color: #cbd5e1;
    --bs-pagination-active-color: #334155;
}

.page-link {
    color: var(--gti-text-primary);
}

.page-link:hover {
    color: var(--gti-text-primary);
}

/* ============================================
   Dark Mode Toggle Button
============================================ */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 1px solid var(--gti-border-color);
    border-radius: 0.5rem;
    color: var(--gti-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    height: 42px;
    min-height: 42px;
    font-size: 1.125rem;
}

.theme-toggle:hover {
    background-color: var(--gti-bg-body);
    border-color: var(--gti-primary-light);
}

.theme-toggle i {
    transition: transform 0.3s ease;
}

.theme-toggle:hover i {
    transform: rotate(20deg);
}

/* Mostrar/esconder ícones baseado no tema */
.theme-toggle .bi-sun-fill {
    display: none;
}

.theme-toggle .bi-moon-fill {
    display: block;
}

body[data-theme="dark"] .theme-toggle .bi-sun-fill {
    display: block;
}

body[data-theme="dark"] .theme-toggle .bi-moon-fill {
    display: none;
}

/* ============================================
   Logo Switching (Light/Dark Mode)
============================================ */

.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

body[data-theme="dark"] .logo-light {
    display: none;
}

body[data-theme="dark"] .logo-dark {
    display: block;
}

/* ============================================
   Dark Mode - Ajustes de Componentes Bootstrap
============================================ */

body[data-theme="dark"] .modal-content {
    background-color: var(--gti-bg-card);
    color: var(--gti-text-primary);
    border-color: var(--gti-border-color);
}

body[data-theme="dark"] .modal-header {
    border-bottom-color: var(--gti-border-color);
}

body[data-theme="dark"] .modal-footer {
    border-top-color: var(--gti-border-color);
}

body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-select {
    background-color: #0f172a;
    border-color: var(--gti-border-color);
    color: var(--gti-text-primary);
}

body[data-theme="dark"] .form-control:focus,
body[data-theme="dark"] .form-select:focus {
    background-color: #0f172a;
    border-color: var(--gti-blue);
    color: var(--gti-text-primary);
}

/* Placeholders globais no modo dark */
body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder,
body[data-theme="dark"] .form-control::placeholder,
body[data-theme="dark"] .form-select::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

body[data-theme="dark"] .dropdown-menu {
    /* Sobrescreve TODAS as variáveis CSS do Bootstrap que afetam cor */
    --bs-body-color: #f1f5f9 !important;
    --bs-dropdown-color: #f1f5f9 !important;
    --bs-dropdown-link-color: #f1f5f9 !important;
    --bs-dropdown-link-hover-color: #f1f5f9 !important;
    --bs-dropdown-link-active-color: #f1f5f9 !important;
    --bs-link-color: #f1f5f9 !important;
    --bs-body-bg: #1e293b !important;
    --bs-dropdown-bg: #1e293b !important;
    
    background-color: var(--gti-bg-card) !important;
    border-color: var(--gti-border-color) !important;
    color: #f1f5f9 !important;
}

/* FORÇA ABSOLUTA: Sobrescreve tudo dentro do dropdown */
body[data-theme="dark"] .dropdown-menu * {
    color: #f1f5f9 !important;
}

/* Especificidade extra para labels e textos */
body[data-theme="dark"] .dropdown-menu label,
body[data-theme="dark"] .dropdown-menu div,
body[data-theme="dark"] .dropdown-menu span,
body[data-theme="dark"] .dropdown-menu option {
    color: #f1f5f9 !important;
}

body[data-theme="dark"] .dropdown-item {
    color: var(--gti-text-primary);
}

body[data-theme="dark"] .dropdown-item:hover,
body[data-theme="dark"] .dropdown-item:focus {
    background-color: #334155;
    color: var(--gti-text-primary);
}

body[data-theme="dark"] .dropdown-divider {
    border-top-color: var(--gti-border-color);
}

/* Estilos para elementos de formulário dentro de dropdowns no dark mode */
body[data-theme="dark"] .dropdown-menu form,
body[data-theme="dark"] .dropdown-menu form * {
    color: #f1f5f9 !important;
}

/* Força cor em TODOS os elementos de texto do dropdown */
body[data-theme="dark"] .dropdown-menu > *,
body[data-theme="dark"] .dropdown-menu div,
body[data-theme="dark"] .dropdown-menu span,
body[data-theme="dark"] .dropdown-menu p,
body[data-theme="dark"] .dropdown-menu label * {
    color: #f1f5f9 !important;
}

body[data-theme="dark"] .dropdown-menu .form-label,
body[data-theme="dark"] .dropdown-menu label,
body[data-theme="dark"] .dropdown-menu .form-check-label {
    color: #f1f5f9 !important;
}

body[data-theme="dark"] .dropdown-menu .form-label.small,
body[data-theme="dark"] .dropdown-menu .form-label.small.fw-semibold,
body[data-theme="dark"] .dropdown-menu label.small.fw-semibold,
body[data-theme="dark"] .dropdown-menu .small.fw-semibold {
    color: #f1f5f9 !important;
}

body[data-theme="dark"] .dropdown-menu .text-muted,
body[data-theme="dark"] .dropdown-menu small.text-muted {
    color: #cbd5e1 !important;
}

body[data-theme="dark"] .dropdown-menu .fw-semibold,
body[data-theme="dark"] .dropdown-menu div.fw-semibold,
body[data-theme="dark"] .dropdown-menu .form-check-label .fw-semibold,
body[data-theme="dark"] .dropdown-menu .form-check-label div,
body[data-theme="dark"] .dropdown-menu .relationship-choice-item div,
body[data-theme="dark"] .dropdown-menu .relationship-choice-item .fw-semibold {
    color: #f1f5f9 !important;
}

/* Força cor clara em divs dentro de labels nos filtros (corrige #212529) */
body[data-theme="dark"] .dropdown-menu label div.fw-semibold,
body[data-theme="dark"] .dropdown-menu .form-check-label > div.fw-semibold,
body[data-theme="dark"] .dropdown-menu .form-check-label > div {
    color: #f1f5f9 !important;
}

/* Sobrescreve qualquer estilo inline ou de classe Bootstrap que defina cor escura */
body[data-theme="dark"] .dropdown-menu [style*="color: #212529"],
body[data-theme="dark"] .dropdown-menu [style*="color:#212529"],
body[data-theme="dark"] .dropdown-menu [class*="text-dark"] {
    color: #f1f5f9 !important;
}

/* Força cor clara em TODOS os elementos dentro de column-filter-form no dark mode */
body[data-theme="dark"] .column-filter-form,
body[data-theme="dark"] .column-filter-form *,
body[data-theme="dark"] .column-filter-form *:not(input):not(select):not(textarea):not(button) {
    --bs-body-color: #f1f5f9 !important;
    color: #f1f5f9 !important;
}

body[data-theme="dark"] .column-filter-form .text-muted,
body[data-theme="dark"] .column-filter-form small.text-muted {
    color: #cbd5e1 !important;
}

/* FORÇA MÁXIMA: Sobrescreve Bootstrap em todos os níveis aninhados */
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown *,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown div,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown span,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown p,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown label,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown .form-label,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown .form-check-label,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown .fw-semibold,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown div.fw-semibold,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown small:not(.text-muted),
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown .relationship-choice-item,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown .relationship-choice-item > *,
body[data-theme="dark"] .dropdown-menu.column-filter-dropdown .form-check-label > div {
    color: #f1f5f9 !important;
}

body[data-theme="dark"] .dropdown-menu .form-control,
body[data-theme="dark"] .dropdown-menu .form-select,
body[data-theme="dark"] .dropdown-menu input[type="text"],
body[data-theme="dark"] .dropdown-menu input[type="date"],
body[data-theme="dark"] .dropdown-menu input[type="number"],
body[data-theme="dark"] .dropdown-menu select,
body[data-theme="dark"] .dropdown-menu textarea {
    background-color: #0f172a !important;
    border-color: var(--gti-border-color) !important;
    color: var(--gti-text-primary) !important;
}

/* Placeholder text em dark mode */
body[data-theme="dark"] .dropdown-menu input::placeholder,
body[data-theme="dark"] .dropdown-menu textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

body[data-theme="dark"] .dropdown-menu .form-control:focus,
body[data-theme="dark"] .dropdown-menu .form-select:focus,
body[data-theme="dark"] .dropdown-menu input:focus,
body[data-theme="dark"] .dropdown-menu select:focus,
body[data-theme="dark"] .dropdown-menu textarea:focus {
    background-color: #0f172a !important;
    border-color: var(--gti-blue) !important;
    color: var(--gti-text-primary) !important;
}

body[data-theme="dark"] .dropdown-menu .form-control::placeholder,
body[data-theme="dark"] .dropdown-menu input::placeholder,
body[data-theme="dark"] .dropdown-menu textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

body[data-theme="dark"] .dropdown-menu option {
    background-color: #1e293b !important;
    color: var(--gti-text-primary) !important;
}

body[data-theme="dark"] .dropdown-menu .form-check-input {
    background-color: #0f172a !important;
    border-color: var(--gti-border-color) !important;
}

body[data-theme="dark"] .dropdown-menu .form-check-input:checked {
    background-color: var(--gti-blue) !important;
    border-color: var(--gti-blue) !important;
}

body[data-theme="dark"] .dropdown-menu .relationship-choices-container {
    background-color: #0f172a !important;
    border-color: var(--gti-border-color) !important;
}

body[data-theme="dark"] .table {
    color: var(--gti-text-primary);
    border-color: var(--gti-border-color);
}

body[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: var(--gti-bg-card);
    border-bottom-color: var(--gti-border-color);
    color: var(--gti-text-primary);
}

body[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #1a2332;
}

body[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(even) > * {
    background-color: var(--gti-bg-card);
}

body[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: #334155 !important;
}

body[data-theme="dark"] .table thead th {
    background-color: #334155;
    color: var(--gti-text-primary);
    border-color: var(--gti-border-color);
}

body[data-theme="dark"] .breadcrumb {
    background-color: transparent;
}

body[data-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
    color: var(--gti-text-secondary);
}

body[data-theme="dark"] .pagination {
    --bs-pagination-bg: var(--gti-bg-card);
    --bs-pagination-border-color: var(--gti-border-color);
    --bs-pagination-color: var(--gti-text-primary);
    --bs-pagination-hover-bg: #334155;
    --bs-pagination-hover-color: var(--gti-text-primary);
    --bs-pagination-active-bg: #475569;
    --bs-pagination-active-border-color: #475569;
    --bs-pagination-active-color: #ffffff;
}

body[data-theme="dark"] .page-link {
    color: var(--gti-text-primary) !important;
}

body[data-theme="dark"] .page-link:hover {
    color: var(--gti-text-primary) !important;
}

body[data-theme="dark"] .page-item.active .page-link {
    color: #ffffff !important;
}

/* Rodapé da paginação em dark mode */
body[data-theme="dark"] .card-footer.bg-white {
    background-color: var(--gti-bg-card) !important;
    border-top: 1px solid var(--gti-border-color);
}

body[data-theme="dark"] .card-footer .text-muted {
    color: var(--gti-text-secondary) !important;
}

/* Alerts em dark mode */
body[data-theme="dark"] .alert {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--gti-border-color);
    color: var(--gti-text-primary);
}

body[data-theme="dark"] .alert-success {
    background-color: rgba(16, 185, 129, 0.15);
    border-left-color: var(--gti-success);
    color: #6ee7b7;
}

body[data-theme="dark"] .alert-warning {
    background-color: rgba(245, 158, 11, 0.15);
    border-left-color: var(--gti-warning);
    color: #fbbf24;
}

body[data-theme="dark"] .alert-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border-left-color: var(--gti-danger);
    color: #fca5a5;
}

body[data-theme="dark"] .alert-info {
    background-color: rgba(6, 182, 212, 0.15);
    border-left-color: var(--gti-info);
    color: #67e8f9;
}

/* Badges em dark mode */
body[data-theme="dark"] .badge {
    background-color: #334155;
    color: var(--gti-text-primary);
}

/* Badge de status */
body[data-theme="dark"] .badge.bg-success {
    background-color: var(--gti-success) !important;
    color: #ffffff !important;
}

body[data-theme="dark"] .badge.bg-warning {
    background-color: var(--gti-warning) !important;
    color: #ffffff !important;
}

body[data-theme="dark"] .badge.bg-danger {
    background-color: var(--gti-danger) !important;
    color: #ffffff !important;
}

/* Text muted em dark mode */
body[data-theme="dark"] .text-muted {
    color: var(--gti-text-secondary) !important;
}

/* Links em dark mode */
body[data-theme="dark"] a {
    color: #3b82f6;
}

body[data-theme="dark"] a:hover {
    color: #60a5fa;
}

/* Links no sidebar devem manter cor clara */
body[data-theme="dark"] .sidebar a {
    color: var(--gti-text-sidebar);
}

body[data-theme="dark"] .sidebar a:hover {
    color: #ffffff;
}

/* List group em dark mode */
body[data-theme="dark"] .list-group-item {
    background-color: var(--gti-bg-card);
    border-color: var(--gti-border-color);
    color: var(--gti-text-primary);
}

body[data-theme="dark"] .list-group-item:hover {
    background-color: #334155;
}

/* Input groups em dark mode */
body[data-theme="dark"] .input-group-text {
    background-color: #334155;
    border-color: var(--gti-border-color);
    color: var(--gti-text-primary);
}

/* GTI Custom Tabs - sem conflito com Bootstrap */
.gti-tabs {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
    border-bottom: 1px solid #dee2e6;
}

.gti-tab-item {
    margin-bottom: -1px;
}

.gti-tab-button {
    display: block;
    padding: 0.5rem 1rem;
    margin-right: 0.5rem;
    color: #6c757d;
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1.5;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.gti-tab-button:hover,
.gti-tab-button:focus {
    color: #495057;
    background-color: #f5f5f5;
    outline: none;
    box-shadow: none;
}

.gti-tab-button.active {
    color: #495057;
    background-color: transparent;
    border-bottom: 2px solid #495057;
    font-weight: 500;
}

.gti-tab-button.active:hover {
    color: #495057;
    background-color: #f5f5f5;
}

/* GTI Custom Tabs - Dark Mode */
body[data-theme="dark"] .gti-tabs {
    border-bottom-color: var(--gti-border-color);
}

body[data-theme="dark"] .gti-tab-button {
    color: var(--gti-text-secondary);
}

body[data-theme="dark"] .gti-tab-button:hover,
body[data-theme="dark"] .gti-tab-button:focus {
    color: var(--gti-text-primary);
    background-color: rgba(100, 116, 139, 0.1);
}

body[data-theme="dark"] .gti-tab-button.active {
    color: var(--gti-text-primary);
    border-bottom-color: var(--gti-text-primary);
}

/* Nav tabs em light mode - sobrescreve Bootstrap */
body:not([data-theme="dark"]) .nav-tabs {
    border-bottom: 1px solid #dee2e6 !important;
}

body:not([data-theme="dark"]) .nav-tabs .nav-link,
body:not([data-theme="dark"]) .nav-tabs button.nav-link {
    color: #6c757d !important;
    background-color: transparent !important;
    border: none !important;
    padding: 0.5rem 1rem !important;
    margin-right: 0.5rem !important;
    border-radius: 0 !important;
}

body:not([data-theme="dark"]) .nav-tabs .nav-link:hover,
body:not([data-theme="dark"]) .nav-tabs .nav-link:focus,
body:not([data-theme="dark"]) .nav-tabs button.nav-link:hover,
body:not([data-theme="dark"]) .nav-tabs button.nav-link:focus {
    color: #495057 !important;
    background-color: #f5f5f5 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    isolation: auto !important;
}

body:not([data-theme="dark"]) .nav-tabs .nav-link.active,
body:not([data-theme="dark"]) .nav-tabs button.nav-link.active {
    color: #495057 !important;
    background-color: transparent !important;
    border: none !important;
    border-bottom: 2px solid #495057 !important;
    font-weight: 500 !important;
}

body:not([data-theme="dark"]) .nav-tabs .nav-link.active:hover,
body:not([data-theme="dark"]) .nav-tabs button.nav-link.active:hover {
    color: #495057 !important;
    background-color: #f5f5f5 !important;
    border: none !important;
    border-bottom: 2px solid #495057 !important;
}

body:not([data-theme="dark"]) .nav-tabs .nav-link:focus-visible,
body:not([data-theme="dark"]) .nav-tabs button.nav-link:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* Nav tabs em dark mode */
body[data-theme="dark"] .nav-tabs {
    border-bottom-color: var(--gti-border-color) !important;
}

body[data-theme="dark"] .nav-tabs .nav-link {
    color: var(--gti-text-secondary) !important;
    border-color: transparent !important;
}

body[data-theme="dark"] .nav-tabs .nav-link:hover {
    color: var(--gti-text-primary) !important;
    background-color: rgba(100, 116, 139, 0.1) !important;
    border-color: var(--gti-border-color) !important;
}

body[data-theme="dark"] .nav-tabs .nav-link.active {
    background-color: var(--gti-bg-card) !important;
    border-color: var(--gti-border-color) var(--gti-border-color) var(--gti-bg-card) !important;
    color: var(--gti-text-primary) !important;
}

/* Close button em dark mode */
body[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Botão de copiar base64 - cores neutras */
.copy-base64-btn {
    border-color: var(--gti-text-primary) !important;
    color: var(--gti-text-primary) !important;
    background-color: transparent !important;
    opacity: 0.7;
}

.copy-base64-btn:hover {
    background-color: rgba(0, 0, 0, 0.05) !important;
    opacity: 1;
}

body[data-theme="dark"] .copy-base64-btn {
    border-color: var(--gti-text-primary) !important;
    color: var(--gti-text-primary) !important;
    opacity: 0.7;
}

body[data-theme="dark"] .copy-base64-btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    opacity: 1;
}

/* Botões no dark mode - garantir texto branco */
body[data-theme="dark"] .btn-primary {
    background-color: #475569;
    border-color: #475569;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-primary:hover {
    background-color: #64748b;
    border-color: #64748b;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-success {
    background-color: #15803d;
    border-color: #15803d;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-success:hover {
    background-color: #16a34a;
    border-color: #16a34a;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-danger {
    background-color: #b91c1c;
    border-color: #b91c1c;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-danger:hover {
    background-color: #dc2626;
    border-color: #dc2626;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-warning {
    background-color: #ca8a04;
    border-color: #ca8a04;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-warning:hover {
    background-color: #eab308;
    border-color: #eab308;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-info {
    background-color: #0369a1;
    border-color: #0369a1;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-info:hover {
    background-color: #0284c7;
    border-color: #0284c7;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-secondary {
    background-color: #475569;
    border-color: #475569;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-secondary:hover {
    background-color: #64748b;
    border-color: #64748b;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-outline-secondary {
    color: var(--gti-text-primary);
    border-color: var(--gti-border-color);
}

body[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #334155;
    border-color: var(--gti-border-color);
    color: #ffffff;
}

body[data-theme="dark"] .btn-light {
    background-color: #475569;
    border-color: #475569;
    color: #ffffff !important;
}

body[data-theme="dark"] .btn-light:hover {
    background-color: #64748b;
    border-color: #64748b;
    color: #ffffff !important;
}

/* Cards em dark mode */
body[data-theme="dark"] .card {
    background-color: var(--gti-bg-card);
    border-color: var(--gti-border-color);
    color: var(--gti-text-primary);
}

body[data-theme="dark"] .card-header {
    background-color: #334155;
    border-bottom-color: var(--gti-border-color);
    color: var(--gti-text-primary);
}

body[data-theme="dark"] .card-footer {
    background-color: #334155;
    border-top-color: var(--gti-border-color);
    color: var(--gti-text-primary);
}

/* Badges em dark mode */
body[data-theme="dark"] .badge {
    color: #ffffff;
}

body[data-theme="dark"] .badge.bg-light {
    background-color: #475569 !important;
    color: var(--gti-text-primary) !important;
}

body[data-theme="dark"] .badge.bg-secondary {
    background-color: #64748b !important;
}

/* Texto escuro deve ficar claro no dark mode */
body[data-theme="dark"] .text-dark {
    color: var(--gti-text-primary) !important;
}

body[data-theme="dark"] .text-body {
    color: var(--gti-text-primary) !important;
}

body[data-theme="dark"] .text-black-50 {
    color: var(--gti-text-secondary) !important;
}

/* Borders em dark mode */
body[data-theme="dark"] .border {
    border-color: var(--gti-border-color) !important;
}

body[data-theme="dark"] hr {
    border-color: var(--gti-border-color);
    opacity: 0.5;
}

/* Alertas em dark mode */
body[data-theme="dark"] .alert {
    color: var(--gti-text-primary);
    border-color: var(--gti-border-color);
}

body[data-theme="dark"] .alert-info {
    background-color: #1e3a5f;
    border-color: #2563eb;
    color: #93c5fd;
}

body[data-theme="dark"] .alert-warning {
    background-color: #3d2e1f;
    border-color: #f59e0b;
    color: #fcd34d;
}

body[data-theme="dark"] .alert-danger {
    background-color: #3d1f1f;
    border-color: #dc2626;
    color: #fca5a5;
}

body[data-theme="dark"] .alert-success {
    background-color: #1f3d2e;
    border-color: #10b981;
    color: #86efac;
}
