/* --- Reset Básico & Fontes --- */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap');

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Open Sans', sans-serif;
    background-color: #f4f7f6;
    color: #333;
}

body {
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Evita rolagem horizontal */
}

/* --- Estrutura Principal --- */
.container {
    width: 90%;
    max-width: 1400px;
    margin: 0 auto;
}

main.container {
    flex-grow: 1; /* Faz o main ocupar o espaço disponível */
    padding-top: 20px;
    padding-bottom: 40px;
}

/* --- Cabeçalho (Header) --- */
header {
    background-color: #171C28;
    color: #fff;
    padding: 10px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    /* Posição relativa para o menu mobile */
    position: relative;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header .logo {
    max-width: 150px;
    height: auto;
    max-height: 50px;
    z-index: 101; /* Garante que o logo fique acima do menu mobile */
}

header nav {
    display: flex;
    align-items: center;
}

header nav a {
    color: #fff;
    text-decoration: none;
    padding: 10px 15px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

header nav a:hover {
    background-color: #2c3e50;
}

header nav a.btn-logout {
    background-color: #e74c3c;
    margin-left: 15px;
}

header nav a.btn-logout:hover {
    background-color: #c0392b;
}

/* --- Botão Hamburger (Escondido no Desktop) --- */
.menu-toggle {
    display: none; /* Escondido por padrão */
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 101;
}
.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #fff;
    margin: 5px 0;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* --- Rodapé (Footer) --- */
footer {
    background-color: #171C28;
    color: #fff;
    text-align: center;
    padding: 20px 0;
    margin-top: auto; /* Empurra o rodapé para baixo */
}

/* --- Página Home (index.php) --- */
.home-container {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    text-align: center;
    margin-top: 20px;
}
.home-container h1 {
    font-size: 2.5rem;
    color: #171C28;
    margin-bottom: 15px;
}
.home-container p {
    font-size: 1.2rem;
    color: #555;
    margin-bottom: 30px;
}
.cta-buttons a {
    display: inline-block;
    text-decoration: none;
    color: #fff;
    background-color: #007bff;
    padding: 15px 30px;
    border-radius: 5px;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 10px;
    transition: background-color 0.2s ease, transform 0.2s ease;
}
.cta-buttons a:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

/* --- Formulários (cadastro.php, editar.php) --- */
.form-container {
    background-color: #ffffff;
    padding: 30px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.form-container h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 30px;
    color: #171C28;
}
.form-container form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 30px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}
.form-group-full-width {
    grid-column: 1 / -1; /* Ocupa as duas colunas */
}
.form-container input[type="text"],
.form-container input[type="url"],
.form-container input[type="password"], /* (ADICIONADO) */
.form-container select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
}
.form-container button[type="submit"] {
    grid-column: 1 / -1; /* Ocupa as duas colunas */
    background-color: #28a745;
    color: white;
    padding: 15px;
    border: none;
    border-radius: 5px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: 10px;
}
.form-container button[type="submit"]:hover {
    background-color: #218838;
}
/* Estilo para os grupos de idioma (de cadastro/editar.php) */
.language-group {
    grid-column: 1 / -1;
    border: 1px solid #e0e0e0;
    padding: 20px;
    border-radius: 8px;
    background: #f9f9f9;
}
.language-group h3 {
    margin-top: 0;
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
    color: #007bff;
}
.language-group-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 30px;
}


/* --- Página de Listagem (lista.php) --- */
.list-container {
    background-color: #ffffff;
    padding: 30px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.list-container h2 {
    margin-top: 0;
    margin-bottom: 30px;
    color: #171C28;
}
.search-container {
    display: flex;
    margin-bottom: 20px;
}
.search-container form {
    display: flex;
    width: 100%;
}
.search-container input[type="text"] {
    flex-grow: 1;
    border: 1px solid #ccc;
    padding: 10px;
    border-radius: 5px 0 0 5px;
    font-size: 16px;
    margin: 0;
    min-width: 100px; /* Garante tamanho mínimo */
}
.search-container form button,
.search-container form .btn-reset-search {
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin-left: -1px;
    border-radius: 0;
    white-space: nowrap; /* Impede que o texto quebre */
}
.search-container form button {
    background-color: #007bff;
    color: white;
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
}
.search-container form button:hover {
    background-color: #0056b3;
}
.search-container form .btn-reset-search {
    background-color: #6c757d;
    color: white;
    font-size: 16px;
    text-decoration: none;
    font-weight: 600;
}
.search-container form .btn-reset-search:hover {
    background-color: #5a6268;
}
.search-container form *:last-child {
    border-radius: 0 5px 5px 0;
}
.table-wrapper {
    overflow-x: auto; /* Permite rolagem horizontal em telas pequenas */
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid #ddd;
    vertical-align: middle;
}
th {
    background-color: #171C28;
    color: white;
    font-size: 14px;
    white-space: nowrap;
}
tr:nth-child(even) {
    background-color: #f9f9f9;
}
tr:hover {
    background-color: #f1f1f1;
}
td a {
    color: #007bff;
    text-decoration: none;
    font-weight: 600;
}
td a:hover {
    text-decoration: underline;
}
.status-ativo {
    color: #28a745;
    font-weight: 700;
}
.status-suspenso {
    color: #ffc107;
    font-weight: 700;
}
td.actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    white-space: nowrap;
}
.btn-action {
    display: inline-block;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    text-align: center;
    transition: background-color 0.2s ease;
    border: none;
    cursor: pointer;
    font-family: 'Open Sans', sans-serif;
}
.btn-edit { background-color: #007bff; }
.btn-edit:hover { background-color: #0056b3; }
.btn-suspend { background-color: #ffc107; color: #212529;}
.btn-suspend:hover { background-color: #e0a800; }
.btn-activate { background-color: #28a745; }
.btn-activate:hover { background-color: #218838; }
.btn-delete { background-color: #dc3545; }
.btn-delete:hover { background-color: #c82333; }


/* --- Estilos da Tabela Expansível (Acordeão) --- */
.group-row-toggle {
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.group-row-toggle:hover {
    background-color: #f1f1f1 !important; /* !important para sobrescrever nth-child */
}
.group-row-toggle td:first-child {
    position: relative;
    padding-left: 30px !important; /* Espaço para o ícone */
}
/* Ícone '+' */
.group-row-toggle td:first-child::before {
    content: '+';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    font-size: 1.2rem;
    color: #007bff;
    transition: transform 0.2s ease;
}
/* Ícone '-' quando 'active' */
.group-row-toggle.active td:first-child::before {
    content: '−'; /* (U+2212) */
    color: #dc3545;
    transform: translateY(-50%) rotate(180deg);
}
.group-row-toggle.active {
     background-color: #f8f9fa;
}

.group-details-row td {
    padding: 0 !important; /* Remove padding da célula da sub-tabela */
    border-bottom: none !important; /* Remove borda dupla */
}
.details-wrapper {
    display: none; /* Escondido por padrão */
    padding: 20px 25px 25px 30px; /* Mais padding à esquerda para alinhar */
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    animation: fadeIn 0.3s ease;
}
/* Mostra o wrapper quando a linha principal está ativa */
.group-row-toggle.active + .group-details-row .details-wrapper {
    display: block;
}

/* Título da sub-tabela (usado em estatisticas.php) */
.list-container .details-wrapper h5 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #171C28 !important; /* Força a cor escura */
}

/* Estilo da sub-tabela (usado em estatisticas.php) */
.sub-table {
    width: 100%;
    border: 1px solid #ddd;
    border-collapse: collapse;
}
.sub-table th, .sub-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}
.sub-table th {
    background-color: #343a40; /* Fundo escuro */
    color: #ffffff; /* Texto branco */
    font-size: 13px;
    white-space: nowrap;
    font-weight: 600;
}
.sub-table tr:nth-child(even) {
     background-color: #fff;
}
.sub-table tr:last-child td {
    border-bottom: none;
}
/* Animação de fade-in */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Estilos para Preview de Banners (lista.php) --- */
.banner-preview-container {
    display: grid;
    /* Cria um grid responsivo de colunas (mín. 150px, máx. 1fr) */
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}
.banner-preview-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    font-size: 13px;
}
.banner-preview-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #007bff;
    text-transform: uppercase;
}
.banner-preview-thumb {
    width: 100%;
    height: auto;
    border: 1px solid #eee;
    margin-bottom: 8px;
    background-color: #f4f7f6;
    min-height: 50px; /* Garante altura mínima se a imagem falhar */
}
.banner-preview-link {
    display: block;
    font-size: 12px;
    color: #555;
    word-break: break-all; /* Quebra links longos */
}


/* --- Página de Login (login.php) --- */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #171C28;
}
.login-container {
    background-color: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-align: center;
    width: 100%;
    max-width: 400px;
    margin: 20px; /* Adiciona margem em telas pequenas */
    box-sizing: border-box;
}
.login-container h2 {
    margin-top: 0;
    margin-bottom: 25px;
    color: #171C28;
}
.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 16px;
}
.login-form button {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.2s ease;
}
.login-form button:hover {
    background-color: #0056b3;
}
.error-message {
    color: #dc3545;
    margin-top: 15px;
    font-weight: 600;
}

/* --- Mensagens de Feedback (para cadastro/edição/estatísticas) --- */
.mensagem-feedback, .mensagem-sucesso, .mensagem-erro {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    font-weight: 600;
    font-size: 16px;
    border: 1px solid;
}
.mensagem-sucesso {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}
.mensagem-erro {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* ================================================================
   (NOVO) ESTILOS DAS PÁGINAS DE IA (config_ia.php e analise_ia.php)
================================================================
*/

/* --- Página Config IA --- */
.form-container.ai-config {
    max-width: 800px;
    margin: 20px auto;
}
.form-container .form-group p {
    font-size: 14px;
    color: #6c757d;
    margin-top: -5px;
    margin-bottom: 5px;
}

/* --- Página Análise IA (Chat) --- */
.chat-container {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    padding: 30px 40px;
    margin-top: 20px;
}
.chat-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}
.chat-filters .period-btn {
    background-color: #f4f7f6;
    color: #333;
    border: 1px solid #ddd;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}
.chat-filters .period-btn:hover {
    background-color: #e9ecef;
}
.chat-filters .period-btn.active {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}
.chat-window {
    height: 400px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
    background-color: #f9f9f9;
    margin-bottom: 20px;
}
.chat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}
.chat-message.user {
    align-items: flex-end;
}
.chat-message.user .message-bubble {
    background-color: #007bff;
    color: #fff;
    border-radius: 15px 15px 0 15px;
}
.chat-message.ai {
    align-items: flex-start;
}
.chat-message.ai .message-bubble {
    background-color: #e9ecef;
    color: #333;
    border-radius: 15px 15px 15px 0;
}
.chat-message.error .message-bubble {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.message-bubble {
    padding: 12px 18px;
    max-width: 80%;
    line-height: 1.6;
    /* (NOVO) Permite que a IA quebre linhas e palavras longas */
    white-space: pre-wrap;
    word-break: break-word;
}
/* (NOVO) Estilos para o HTML gerado pela IA */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    margin-bottom: 10px;
    font-size: 13px;
    background-color: #fff;
    border: 1px solid #ccc;
}
.message-bubble th, .message-bubble td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: left;
}
.message-bubble th {
    background-color: #f1f1f1;
}
.message-bubble ul, .message-bubble ol {
    margin-left: 20px;
    padding-left: 10px;
}
.message-bubble p {
    margin-top: 0;
    margin-bottom: 10px;
}
.message-bubble p:last-child {
    margin-bottom: 0;
}

.chat-input-area {
    display: flex;
    gap: 10px;
}
.chat-input-area input {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
}
.chat-input-area button {
    background-color: #28a745;
    color: white;
    padding: 0 25px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}
.chat-input-area button:hover {
    background-color: #218838;
}
.chat-input-area input:disabled,
.chat-input-area button:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.7;
}

/* --- Spinner de Carregamento --- */
.spinner{
    border:6px solid #f3f3f3;
    border-top:6px solid #007bff;
    border-radius:50%;
    width:50px;
    height:50px;
    animation:spin 1s linear infinite;
    margin:40px auto
}
@keyframes spin{
    0%{transform:rotate(0deg)}
    100%{transform:rotate(360deg)}
}


/* ================================================================
   ESTILOS DA PÁGINA DE ESTATÍSTICAS
================================================================
*/
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.stats-card {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border-left: 5px solid #007bff;
}
.stats-card.cliques { border-color: #28a745; }
.stats-card.ctr { border-color: #ffc107; }
.stats-card.urls { border-color: #6f42c1; } /* (ADICIONADO) */


.stats-card h3 {
    margin-top: 0;
    font-size: 16px;
    color: #6c757d;
    text-transform: uppercase;
    font-weight: 600;
}
.stats-card .valor-principal {
    font-size: 2.5rem;
    font-weight: 700;
    color: #171C28;
    margin-bottom: 5px;
}
.stats-card .valor-secundario {
    font-size: 14px;
    color: #555;
}

/* Estilos do Gráfico */
.chart-container-wrapper {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px; /* Espaçamento para quando quebrar a linha */
}
.chart-header h3 {
    margin: 0;
    font-size: 1.2rem;
    flex-basis: 100%; /* Ocupa 100% no mobile (antes de empilhar) */
}
.chart-filters {
    display: flex;
    flex-wrap: wrap; /* Permite que os botões quebrem a linha */
    gap: 5px; /* Espaçamento entre os botões */
}
.chart-filters a {
    text-decoration: none;
    padding: 8px 12px;
    background-color: #f4f7f6;
    color: #555;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    margin-left: 0; /* Remove margem antiga */
}
.chart-filters a.active {
    background-color: #007bff;
    color: #fff;
}

/* Estilos das Tabelas de Top */
.grid-duplo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}
.table-container {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    overflow-x: auto; /* Permite rolagem interna da tabela */
}
.table-container h3 {
    margin-top: 0;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}
.table-container table {
    width: 100%;
}
.table-container table td {
    padding: 8px 5px;
}
.table-container .url-wrap {
    word-break: break-all;
    font-size: 13px;
    line-height: 1.4;
    font-weight: 600;
}
.table-container .url-wrap:hover {
    text-decoration: underline;
}

/* Estilos do Botão de Reset */
.reset-container {
    background-color: #fff1f2;
    border: 1px solid #dc3545;
    border-radius: 8px;
    padding: 20px 30px;
    margin-top: 40px;
    text-align: center;
}
.reset-container h3 {
    margin-top: 0;
    color: #dc3545;
}
.reset-container p {
    font-size: 15px;
}
.btn-resetar-logs {
    background-color: #dc3545;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.btn-resetar-logs:hover {
    background-color: #c82333;
}

/* Estilos para Auto-Refresh (Estatísticas) */
.auto-refresh-container {
    background-color: #f8f9fa; /* Um cinza claro */
    border: 1px solid #dee2e6;
    padding: 20px 30px;
    border-radius: 8px;
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Permite quebrar linha em telas pequenas */
    gap: 15px;
}
.auto-refresh-container h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #171C28;
}
.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 15px; 
}
.auto-refresh-status {
    font-weight: 700;
    font-size: 14px;
}
.auto-refresh-countdown {
    font-size: 13px;
    color: #6c757d; 
    font-weight: 600;
    min-width: 120px; 
    text-align: right;
}
.switch{position:relative;display:inline-block;width:60px;height:34px;margin-top:10px}
.switch input{opacity:0;width:0;height:0}
.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;transition:.4s}
.slider:before{position:absolute;content:"";height:26px;width:26px;left:4px;bottom:4px;background-color:white;transition:.4s}
input:checked + .slider{background-color:#28a745}
input:checked + .slider:before{transform:translateX(26px)}
.slider.round{border-radius:34px}
.slider.round:before{border-radius:50%}

/* Estilos para Modal de Gráfico (Estatísticas) */
.modal{display:none;position:fixed;z-index:1000;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:rgba(0,0,0,.5);animation:fadeInModal .3s}
.modal-content{background-color:#fff;margin:8% auto;padding:25px 30px;border:1px solid #888;width:80%;max-width:900px;border-radius:8px;position:relative;box-shadow:0 5px 15px rgba(0,0,0,.3);animation:slideInModal .3s ease-out}
.close-modal-btn{color:#aaa;float:right;font-size:28px;font-weight:bold;cursor:pointer;line-height:1}
.close-modal-btn:hover,.close-modal-btn:focus{color:#000;text-decoration:none}
.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;padding-bottom:15px;border-bottom:1px solid #eee}
.modal-header h3{margin:0;font-size:1.4rem;color:#171C28}
.chart-controls .chart-range-btn{background-color:#f0f0f0;border:1px solid #ddd;color:#333;padding:5px 10px;border-radius:4px;cursor:pointer;font-size:13px;font-weight:600}
.chart-controls .chart-range-btn:hover{background-color:#e9e9e9}
.chart-controls .chart-range-btn.active{background-color:#007bff;color:#fff;border-color:#007bff}
@keyframes fadeInModal{from{opacity:0}to{opacity:1}}
@keyframes slideInModal{from{opacity:0;transform:translateY(-50px)}to{opacity:1;transform:translateY(0)}}
tr.clickable-row-chart { cursor: pointer; }
tr.group-details-row:hover, tr.clickable-row-chart:hover + tr.group-details-row { background-color: transparent !important; }
tr.clickable-row-chart:hover { background-color: #f1f1f1 !important; }

/* Tabela de Horários (Estatísticas) */
.horario-bar-bg{background-color:#e9ecef;border-radius:4px;height:10px;width:100%}
.horario-bar{background-color:#007bff;height:10px;border-radius:4px}

/* Ordenação de Tabela (Estatísticas) */
.table-wrapper th.sortable, .list-container th.sortable{cursor:pointer;position:relative;padding-right:25px !important}
.table-wrapper th.sortable::after, .list-container th.sortable::after, .table-wrapper th.sortable::before, .list-container th.sortable::before{content:'';position:absolute;right:10px;opacity:.3;border:5px solid transparent}
.table-wrapper th.sortable::before, .list-container th.sortable::before{bottom:50%;border-bottom-color:#343a40}
.table-wrapper th.sortable::after, .list-container th.sortable::after{top:50%;border-top-color:#343a40}
.table-wrapper th.sort-asc::before, .list-container th.sort-asc::before{opacity:1;border-bottom-color:#007bff}
.table-wrapper th.sort-desc::after, .list-container th.sort-desc::after{opacity:1;border-top-color:#007bff}


/* ================================================================
   MEDIA QUERIES PARA RESPONSIVIDADE
================================================================
*/
@media (max-width: 900px) {
    /* Quebra o grid das tabelas de estatísticas */
    .grid-duplo {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
    /* --- Responsividade do Header --- */
    header .container {
        position: relative;
    }

    /* (CORRETO) Regras do menu mobile */
    header nav {
        display: none; /* Esconde o menu desktop */
        position: absolute;
        top: 65px; /* Altura do header (ajuste se seu logo for maior) */
        left: 0;
        width: 100%;
        background-color: #171C28;
        flex-direction: column;
        align-items: center;
        padding: 10px 0;
        box-shadow: 0 3px 5px rgba(0,0,0,0.2);
        z-index: 100;
    }
    header nav.mobile-open {
        display: flex; /* Mostra o menu quando clicado */
    }
    header nav a {
        width: 100%;
        text-align: center;
        padding: 15px 0;
        border-bottom: 1px solid #2c3e50;
    }
    header nav a:last-child {
        border-bottom: none;
    }
    header nav a.btn-logout {
        margin-left: 0;
        margin-top: 10px;
        width: 90%;
        box-sizing: border-box;
    }

    .menu-toggle {
        display: block; /* Mostra o botão hamburger */
    }

    /* --- Responsividade Geral --- */
    .container {
        width: 95%; /* Mais largura em telas pequenas */
    }
    main.container {
        padding-top: 15px;
        padding-bottom: 25px;
    }

    /* --- Home Page --- */
    .home-container {
        padding: 25px;
    }
    .home-container h1 {
        font-size: 2rem;
    }
    .home-container p {
        font-size: 1rem;
    }
    .cta-buttons a {
        display: block; /* Botões empilhados */
        margin: 10px 0;
        padding: 15px;
    }

    /* --- Formulários --- */
    .form-container {
        padding: 20px;
    }
    .form-container form,
    .language-group-fields {
        /* Coluna única em telas menores */
        grid-template-columns: 1fr;
    }
    .form-group-full-width {
        grid-column: auto; /* Reseta para o padrão de 1 coluna */
    }
    .language-group {
        padding: 15px;
    }

    /* --- Página de Listagem --- */
    .list-container {
        padding: 20px;
    }
    .search-container form {
        flex-direction: column; /* Empilha a busca */
        gap: 5px;
    }
    .search-container input[type="text"] {
        border-radius: 5px;
    }
    .search-container form button,
    .search-container form .btn-reset-search {
        margin-left: 0;
        border-radius: 5px;
    }
    .search-container form *:last-child {
        border-radius: 5px; /* Garante que o último botão seja arredondado */
    }

    /* --- Página de Estatísticas --- */
    .stats-card {
        padding: 20px;
    }
    .stats-card .valor-principal {
        font-size: 2rem;
    }
    .chart-container-wrapper {
        padding: 20px;
    }
    .chart-header {
        align-items: flex-start; /* Alinha tudo à esquerda */
    }
    .chart-header h3 {
        font-size: 1.1rem;
    }
    .table-container {
        padding: 20px;
    }
    .reset-container {
        padding: 20px;
    }
    
    /* --- (NOVO) Página de Análise IA --- */
    .chat-container {
        padding: 20px;
    }
    .chat-message.user .message-bubble,
    .chat-message.ai .message-bubble {
        max-width: 95%; /* Bolhas de chat ocupam mais espaço */
    }
}