/* ========================================= */
/* === 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 (do seu header.php) */
    --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;
    /* Removemos o padding-top: 60px; que estava no seu styles.css, 
       pois seu layout de menu-btn é 'fixed' no canto */
    transition: padding-left 0.3s ease;
}

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

/* Estilos do menu (do header.php) */
.sidebar {
    width: 280px; /* Largura unificada */
    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 */
.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; /* Garante que a transição de max-height funcione */
}

.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 */
.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);
}

/* --- A CORREÇÃO PRINCIPAL ESTÁ AQUI --- */

/* 1. O 'content' é o seu container principal que será "empurrado" */
.content {
    transition: margin-left 0.3s;
    /* REMOVEMOS 'max-width' e 'margin: auto' que limitavam a tela */
    width: 100%; /* Garantia de largura total */
}

/* 2. Quando o menu está ativo, o body NÃO deve ter padding */
body.menu-active {
    /* padding-left: 280px; <-- REMOVIDO! Este era o erro que "espremia" a tela. */
    overflow-x: hidden;
}

/* 3. Em vez do padding, NÓS EMPURRAMOS O .content com MARGIN */
body.menu-active .content {
    margin-left: 280px;
}

/* 4. Ajustes para telas menores */
@media (max-width: 768px) {
    .sidebar {
        width: 240px;
        left: -240px;
    }
    
    body.menu-active {
        padding-left: 0; /* Garante que não tenha padding no mobile */
    }
    
    body.menu-active .content {
        margin-left: 240px; /* Ajusta a margem para o menu mobile */
    }
}


/* ========================================= */
/* === ESTILOS DIVERSOS (do styles.css) === */
/* ========================================= */

/* 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;
    /* REMOVEMOS max-height: 400px; e overflow-y: auto; 
       Isso pode ser ruim para tabelas. 
       Se precisar, adicione de volta ou coloque em uma classe específica. */
}

/* 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 */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin-bottom: 1rem;
}

.table {
    width: 100%;
    margin-bottom: 1rem;
    background-color: transparent;
    font-size: 0.85rem;
    /* min-width: 1000px; <-- Removido para melhor responsividade. 
       A div .table-responsive (do Bootstrap) ou .table-container (daqui) 
       já cuida da barra de rolagem horizontal se necessário. */
}

.table th {
    background-color: var(--primary);
    color: white;
    vertical-align: middle;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table td {
    vertical-align: middle;
    white-space: nowrap;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* 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; }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }

/* ========================================= */
/* === ESTILOS DE PÁGINAS ESPECÍFICAS === */
/* ========================================= */

/* --- Página de Perfil --- */
.profile-card {
    max-width: 900px;
    margin: 1rem auto;
}
.profile-card .tab-content {
    max-height: none;
    overflow-y: visible;
}
#main-profile-form {
    display: flex;
    flex-direction: column;
}
#main-profile-form .tab-content {
    flex-grow: 1;
}
.card-body #qrcode-container img {
    max-width: 250px;
    height: auto;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 8px;
}
@media (min-width: 992px) {
    #api.tab-pane {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
        align-items: start;
    }
    #api .connection-card { grid-column: 1 / 2; }
    #api .message-templates { grid-column: 2 / 3; }
}
#password form {
    max-width: 400px;
    margin: 0 auto;
}