/* ========================================= */
/* === CONFIGURAÇÕES GLOBAIS E CORES === */
/* ========================================= */

:root {
    --primary: #4a6fa5;
    --secondary: #166088;
    --success: #28a745;
    --danger: #dc3545;
    --light: #f8f9fa;
    --dark: #343a40;
    --warning: #ffc107;
    --info: #17a2b8;
    
    /* Cores do Sidebar antigo (Mantido para fallback) */
    --sidebar-bg: #4a6fa5;
    --sidebar-hover: #166088;
    --sidebar-text: #ffffff;
    --submenu-bg: #3a5a80;
    --menu-btn: #28a745;
    --menu-btn-hover: #218838;
}

/* Reset e estilos base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    transition: padding-left 0.3s ease;
}

/* ========================================= */
/* === LAYOUT PRINCIPAL E SIDEBAR (LEGADO) === */
/* ========================================= */

/* Estilos do menu antigo */
.sidebar {
    width: 280px; 
    height: 100vh;
    position: fixed;
    left: -280px;
    top: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar.active {
    left: 0;
}

.sidebar h2 {
    color: var(--sidebar-text);
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    font-size: 1.4rem;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    margin-bottom: 8px;
}

.sidebar li a {
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
    padding: 12px 15px;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.sidebar li a:hover {
    background: var(--sidebar-hover);
    transform: translateX(5px);
}

.sidebar li a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

/* Submenu antigo */
.submenu-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 15px;
    background: var(--submenu-bg);
    border-radius: 6px;
    margin-top: 5px;
    display: block; 
}

.submenu-list.active {
    max-height: 800px;
}

.submenu-list li a {
    padding: 10px 15px;
    font-size: 0.9rem;
}

.submenu > a::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: auto;
    transition: transform 0.3s;
}

.submenu.active > a::after {
    transform: rotate(180deg);
}

/* Botões do Menu antigo */
.menu-btn {
    position: fixed;
    left: 20px;
    top: 20px;
    z-index: 999;
    background: var(--menu-btn);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-btn:hover {
    background: var(--menu-btn-hover);
    transform: scale(1.05);
}

.close-btn {
    position: absolute;
    right: 15px;
    top: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    transform: rotate(90deg);
}

.content {
    transition: margin-left 0.3s;
    width: 100%; 
}

body.menu-active {
    overflow-x: hidden;
}

body.menu-active .content {
    margin-left: 280px;
}

@media (max-width: 768px) {
    .sidebar {
        width: 240px;
        left: -240px;
    }
    
    body.menu-active {
        padding-left: 0; 
    }
    
    body.menu-active .content {
        margin-left: 240px; 
    }
}


/* ========================================= */
/* === ESTILOS DIVERSOS === */
/* ========================================= */

/* Dashboard */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Cards */
.card {
    border: 1px solid rgba(0,0,0,0.125);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.card-header {
    font-weight: 600;
    padding: 12px 15px;
    border-bottom: 1px solid rgba(0,0,0,0.125);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 15px;
}

/* Cores específicas para cards */
.card-vence-hoje { border-color: var(--warning); }
.card-vence-hoje .card-header { background-color: var(--warning); color: var(--dark); }
.card-vencidos { border-color: var(--danger); }
.card-vencidos .card-header { background-color: var(--danger); color: white; }
.card-3dias { border-color: var(--info); }
.card-3dias .card-header { background-color: var(--info); color: white; }

/* Formulários e inputs */
.form-control {
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    border: 1px solid #ced4da;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(74, 111, 165, 0.25);
}

/* Barra de pesquisa */
#search {
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* Botões */
.btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background-color: var(--secondary);
    border-color: var(--secondary);
}
.btn-group { flex-wrap: nowrap; }
.btn-group-sm .btn { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

/* Tabelas (Legado) */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin-bottom: 1rem;
}

/* Cards de saldo */
.balance-card { min-height: 100px; color: white; }
.balance-card .card-body { padding: 1rem; }
.balance-card .card-title { font-size: 1rem; margin-bottom: 0.5rem; }
.balance-card .card-text { font-size: 1.25rem; font-weight: bold; }

/* Ícones */
.app-icon { width: 24px; height: 24px; object-fit: contain; margin-right: 8px; }
.copy-button img { max-width: 16px; }

/* Clientes */
.cliente-container { padding: 10px 0; margin-bottom: 15px; border-bottom: 1px solid #eee; }
.cliente-container:last-child { border-bottom: none; }
.cliente-container p { margin-bottom: 10px; }

/* Mensagens */
.empty-message { color: #6c757d; font-style: italic; text-align: center; padding: 10px; }
.alert { position: relative; padding: 0.75rem 1.25rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 0.25rem; }
.alert-success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.alert-danger { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }

/* Utilitários */
.text-truncate { max-width: 100px; display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }


/* ==========================================================================
   TEMA ESCURO GLOBAL (APLICA EM TODAS AS PÁGINAS)
   ========================================================================== */

/* Substitui a cor de fundo clara pelo fundo escuro do menu */
body.bg-light, body.bg-white, body {
    background-color: #0f172a !important; /* Azul bem escuro (fundo da tela) */
    color: #f8fafc !important; /* Texto branco/cinza claro */
}

/* Modifica a barra superior do header.php para ficar escura */
.modern-topbar {
    background-color: #1e293b !important;
    border-bottom: 1px solid #334155 !important;
    color: #f8fafc !important;
}
.modern-topbar .text-secondary {
    color: #f8fafc !important;
}
.modern-topbar .menu-toggle-btn {
    color: #f8fafc !important;
}
.modern-topbar .menu-toggle-btn:hover {
    background-color: #334155 !important;
}

/* Modifica todos os Cards (Tabelas, Formulários, etc) */
.card, .modal-content {
    background-color: #1e293b !important; /* Fundo dos cartões */
    border-color: #334155 !important;
    color: #f8fafc !important;
}
.card-header {
    background-color: rgba(0,0,0,0.2) !important;
    border-bottom: 1px solid #334155 !important;
    color: #f8fafc !important;
}
.card-footer {
    background-color: rgba(0,0,0,0.1) !important;
    border-top: 1px solid #334155 !important;
}

/* Fix das bordas de tabelas para não ficarem brancas */
.border, .border-top, .border-bottom, .border-start, .border-end {
    border-color: #334155 !important;
}

/* ==========================================================================
   CORREÇÃO DEFINITIVA DE TABELAS PARA TEMA ESCURO
   ========================================================================== */
.table {
    color: #f8fafc !important;
    border-color: #334155 !important;
    background-color: transparent !important;
}
/* Força as células das tabelas a ficarem com fundo escuro (Corrige o Bootstrap 5) */
.table > :not(caption) > * > * {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border-bottom-color: #334155 !important;
}
/* Estilo para Tabela Light (Cabeçalhos comuns em algumas de suas páginas) */
.table-light > :not(caption) > * > *, 
.table-light th, .table-light td {
    background-color: #334155 !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}
/* Estilo para Tabela Dark (Cabeçalhos principais) */
.table-dark > :not(caption) > * > *, 
.table-dark th, .table-dark td {
    background-color: #0f172a !important;
    color: #38bdf8 !important;
    border-color: #334155 !important;
}
/* Corrige o efeito zebrado (Tabelas Striped) */
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #27354c !important; /* Cor levemente mais clara que o fundo para destacar a zebra */
    color: #f8fafc !important;
}
/* Corrige o hover nas tabelas */
.table-hover tbody tr:hover > * {
    background-color: rgba(56, 189, 248, 0.1) !important; /* Fundo azul suave ao passar o mouse */
    color: #fff !important;
}

/* ==========================================================================
   CORREÇÃO DE TEXTOS, FORMULÁRIOS E LABELS
   ========================================================================== */

/* FORÇA TODAS AS LABELS E TÍTULOS DE FORMULÁRIOS A SEREM CLAROS */
label, .form-label {
    color: #f8fafc !important; /* Branco/Cinza super claro */
}

/* Modifica Inputs, Selects e Textareas */
.form-control, .form-select {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}
.form-control:focus, .form-select:focus {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25) !important;
}
.form-control::placeholder {
    color: #64748b !important;
}

/* Força os "Options" dentro dos selects normais e multiple a ficarem visíveis */
option {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}

/* Fix para itens de List Group (usado em páginas como a de Cadastros) */
.list-group-item {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}
.list-group-item:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Fix para as Abas de Navegação (Nav-tabs) */
.nav-tabs {
    border-bottom-color: #334155 !important;
}
.nav-tabs .nav-link {
    color: #94a3b8 !important;
}
.nav-tabs .nav-link:hover {
    border-color: #334155 !important;
    color: #f8fafc !important;
}
.nav-tabs .nav-link.active {
    background-color: #1e293b !important;
    border-color: #334155 #334155 #1e293b !important;
    color: #38bdf8 !important;
}

/* Fix para modais com bg-light/white e headers */
.modal-header, .modal-footer {
    border-color: #334155 !important;
}

/* ==========================================================================
   CORREÇÃO EXCLUSIVA PARA A TABELA DE CLIENTES E DROPDOWNS
   ========================================================================== */

/* Fix para Dropdowns de Ações invisíveis/brancos no tema escuro */
.dropdown-menu {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
}
.dropdown-item {
    color: #e2e8f0 !important;
}
.dropdown-item:hover, .dropdown-item:focus {
    background-color: #334155 !important;
    color: #fff !important;
}
.dropdown-divider {
    border-top-color: #475569 !important;
}

/* Fix para textos de Informação na Tabela de Clientes */
.info-label {
    color: #94a3b8 !important; /* Cinza claro suave */
}
.info-value {
    color: #f8fafc !important; /* Branco nítido */
    background-color: transparent !important;
}
.user-highlight {
    background-color: rgba(56, 189, 248, 0.15) !important; /* Fundo azul translúcido bonito */
    color: #38bdf8 !important; /* Texto azul claro */
}
.btn-copy-mini {
    color: #94a3b8 !important;
}
.btn-copy-mini:hover {
    color: #38bdf8 !important;
}

/* Fix para as caixinhas de MAC/KEY/SENHA na tabela de clientes */
.font-monospace.bg-light.border,
.font-monospace.bg-dark.border {
    background-color: #0f172a !important; /* Fundo azul bem escuro */
    border-color: #475569 !important;
    color: #38bdf8 !important; /* Deixa o dado em destaque (azul claro neon) */
}

/* Fix para os links de ordenação no cabeçalho das tabelas */
.table-dark th a,
.table-dark th a.text-white,
.table-dark th a.text-info {
    color: #38bdf8 !important; /* Substitui por azul do tema */
    text-decoration: none !important;
}
.table-dark th a:hover {
    color: #bae6fd !important; /* Brilha no hover */
}
.sort-icon {
    color: #38bdf8 !important;
}

/* ==========================================================================
   CORREÇÃO PLUGIN DE PESQUISA (SELECT2) NO TEMA ESCURO
   ========================================================================== */
.select2-container--bootstrap-5 .select2-selection {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}
.select2-container--bootstrap-5 .select2-selection__rendered {
    color: #f8fafc !important;
}
/* Faz o container de opções selecionadas no múltiple ficar legível */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    background-color: #3b82f6 !important;
    border-color: #2563eb !important;
    color: #ffffff !important;
}
.select2-container--bootstrap-5 .select2-dropdown {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
.select2-container--bootstrap-5 .select2-results__option {
    color: #cbd5e1 !important;
}
.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: #3b82f6 !important;
    color: #fff !important;
}

/* Ajustes de cores semânticas para não sumirem e terem alto contraste */
.text-dark, .text-secondary, .text-muted {
    color: #cbd5e1 !important; /* Cinza claro padrão (sobrescreve textos pretos) */
}
.bg-light, .bg-white {
    background-color: #1e293b !important; /* Sobrescreve fundos brancos engessados nas tags */
}
/* Textos coloridos com ajustes para modo noturno (mais vibrantes) */
.text-primary { color: #38bdf8 !important; } /* Sky Blue */
.text-success { color: #4ade80 !important; } /* Green */
.text-danger { color: #f87171 !important; }  /* Red */
.text-warning { color: #fbbf24 !important; } /* Amber */
.text-info { color: #2dd4bf !important; }    /* Teal */