/* ===================================================
   STYLE.CSS - REDESIGN MODERNO (SISTEMA DE CLIENTES)
   =================================================== */

/* --- Importação da Fonte e Variáveis Globais --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Cores (Tema Claro) */
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    
    /* Cores de Status */
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    --status-info: #3b82f6;
    --status-treating: #6366f1;
    --status-neutral: #6b7280;

    /* Estilos Gerais */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* --- Tema Escuro (Dark Mode) --- */
body.dark-mode {
    --primary-color: #818cf8;
    --primary-hover: #a78bfa;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --border-color: #374151;

    --status-success: #34d399;
    --status-warning: #fbbf24;
    --status-danger: #f87171;
    --status-info: #60a5fa;
    --status-treating: #a5b4fc;
    --status-neutral: #9ca3af;
}

/* --- Reset e Estilos Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1600px;
    margin: 2rem auto;
    padding: 2rem;
}

/* --- Header e Título --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-controls { display: flex; align-items: center; gap: 1rem; }
.header-buttons { display: flex; gap: 0.75rem; }

/* --- Botões --- */
.primary-btn, .secondary-btn, .danger-btn {
    padding: 0.625rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease-in-out;
}
.primary-btn { background-color: var(--primary-color); color: white; }
.primary-btn:hover { background-color: var(--primary-hover); }
.secondary-btn { background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border-color); box-shadow: var(--shadow-sm); }
.secondary-btn:hover { background-color: var(--bg-secondary); }
.danger-btn { background-color: var(--status-danger); color: white; }
.danger-btn:hover { opacity: 0.9; }
.primary-btn:active, .secondary-btn:active, .danger-btn:active { transform: scale(0.98); }

#theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
}
#theme-toggle:hover { background-color: var(--bg-secondary); color: var(--text-primary); }
body.dark-mode #theme-toggle:hover { background-color: #374151; }

/* --- Controles: Busca, Filtros, Visualização --- */
.controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.search-box { flex-grow: 1; min-width: 300px; }
.search-box input { width: 100%; padding: 0.625rem 1rem; border: 1px solid var(--border-color); border-radius: var(--border-radius-md); font-size: 0.875rem; background-color: var(--bg-primary); color: var(--text-primary); transition: border-color 0.2s, box-shadow 0.2s; }
.search-box input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 20%, transparent); }

.view-toggle button { padding: 0.5rem 1rem; border: 1px solid var(--border-color); cursor: pointer; background-color: var(--bg-primary); color: var(--text-secondary); transition: background-color 0.2s; }
.view-toggle button:first-child { border-radius: var(--border-radius-md) 0 0 var(--border-radius-md); }
.view-toggle button:last-child { border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0; border-left: 0; }
.view-toggle button.active { background-color: var(--primary-color); color: white; border-color: var(--primary-color); }

/* --- Filtros --- */
.filter-container { position: relative; }
.filter-trigger { padding: 0.625rem 1rem; border-radius: var(--border-radius-md); background-color: var(--bg-primary); border: 1px solid var(--border-color); cursor: pointer; font-size: 0.875rem; font-weight: 500; }
.filter-card { display: none; position: absolute; top: calc(100% + 0.5rem); right: 0; width: 500px; max-width: 90vw; background-color: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--border-radius-md); box-shadow: var(--shadow-lg); z-index: 100; padding: 1.5rem; }
.filter-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border-color); }
.filter-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.filter-group label { display: block; margin-bottom: 0.5rem; font-size: 0.875rem; font-weight: 500; }
.filter-input { width: 100%; padding: 0.5rem 0.75rem; border-radius: var(--border-radius-md); border: 1px solid var(--border-color); background-color: var(--bg-secondary); color: var(--text-primary); }
.checkbox-item { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-item label { margin: 0; font-weight: 400; }
.date-input-container { display: flex; align-items: center; gap: 0.5rem; }
.filter-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }

/* --- Visualização em Card --- */
.client-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.client-card { background-color: var(--bg-primary); border-radius: var(--border-radius-md); box-shadow: var(--shadow-md); padding: 1.5rem; display: flex; flex-direction: column; transition: transform 0.2s, box-shadow 0.2s; }
.client-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.client-name { font-size: 1.125rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.25rem; }
.client-id { font-size: 0.75rem; color: var(--text-secondary); }
.transaction-details { display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.875rem; margin-bottom: 1rem; }
.detail { display: flex; justify-content: space-between; }
.transaction-amount { font-size: 1.75rem; font-weight: 700; color: var(--primary-color); text-align: center; margin: 1rem 0; }
.card-actions { margin-top: auto; border-top: 1px solid var(--border-color); padding-top: 1rem; display: flex; justify-content: flex-end; }

/* --- Visualização em Tabela --- */
.table-view { display: none; background-color: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--border-radius-md); overflow-x: auto; box-shadow: var(--shadow-md); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); font-size: 0.875rem; white-space: nowrap; }
th { font-weight: 500; color: var(--text-secondary); background-color: var(--bg-secondary); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: color-mix(in srgb, var(--primary-color) 5%, var(--bg-primary)); }
.botoesdtewhatspp { display: flex; align-items: center; gap: 0.5rem; }

/* --- Status Badges --- */
.status-badge { padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; display: inline-block; }
.status-success { background-color: color-mix(in srgb, var(--status-success) 15%, transparent); color: var(--status-success); }
.status-warning { background-color: color-mix(in srgb, var(--status-warning) 15%, transparent); color: var(--status-warning); }
.status-danger { background-color: color-mix(in srgb, var(--status-danger) 15%, transparent); color: var(--status-danger); }
.status-info { background-color: color-mix(in srgb, var(--status-info) 15%, transparent); color: var(--status-info); }
.status-treating { background-color: color-mix(in srgb, var(--status-treating) 15%, transparent); color: var(--status-treating); }
.status-neutral, .status-primary { background-color: color-mix(in srgb, var(--status-neutral) 15%, transparent); color: var(--status-neutral); }
body.dark-mode .status-badge { background-color: color-mix(in srgb, currentColor 25%, transparent); }

/* --- Modal --- */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
.modal-content { background-color: var(--bg-primary); border-radius: var(--border-radius-md); width: 90%; max-width: 1000px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-header {
  display: flex; /* Ativa o Flexbox */
  justify-content: space-between; /* Coloca um item no início (título) e outro no final (botão) */
  align-items: center; /* Alinha os dois verticalmente no centro */
  width: 100%; /* Garante que o cabeçalho ocupe toda a largura */
}

.modal-header .close-modal {
  /* Resetando estilos de botão padrão */
  background: #e53e3e; /* Cor de fundo vermelha (pode ajustar) */
  color: white; /* Cor do X branco */
  border: none;
  border-radius: 50%; /* Deixa o botão perfeitamente redondo */
  
  /* Tamanho e alinhamento do conteúdo */
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* Estilo do texto e transição */
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s;
}

/* Efeito hover para o botão de fechar */
.modal-header .close-modal:hover {
  background-color: #c53030; /* Um vermelho um pouco mais escuro */
}

/* 3. Corrigindo o Layout dos Botões de Anexo */
/* Forçamos o container de anexos a ter espaço suficiente */
.modal-left-container .attachments-container {
  /* Permite que os botões fiquem lado a lado mesmo com pouco espaço */
  flex-wrap: nowrap;
}

/* Opcional: Ajuste para telas menores, se necessário */
@media (max-width: 900px) {
    .modal-left-container .attachments-container {
      flex-wrap: wrap; /* Em telas muito pequenas, permite que os botões quebrem a linha */
    }
}

.modal-body { padding: 1.5rem; display: flex; gap: 1.5rem; overflow-y: auto; flex-grow: 1; }
.modal-left-container, .modal-right-container { flex: 1; min-width: 0; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 0.75rem; }
.detail-group h4 { margin-bottom: 1rem; font-size: 1rem; font-weight: 600; }
.detail-row { display: flex; justify-content: space-between; font-size: 0.875rem; padding: 0.5rem 0; border-bottom: 1px dashed var(--border-color); }
.detail-row span:first-child { color: var(--text-secondary); }
.checklist-item { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.status-select, textarea, input[type="file"] { width: 100%; padding: 0.5rem 0.75rem; border-radius: var(--border-radius-md); border: 1px solid var(--border-color); background-color: var(--bg-secondary); color: var(--text-primary); }
textarea { resize: vertical; min-height: 100px; }

/* --- Notificações, Paginação, Loading --- */
.notification { position: fixed; bottom: -100px; right: 2rem; padding: 1rem 1.5rem; border-radius: var(--border-radius-md); color: white; box-shadow: var(--shadow-lg); transition: bottom 0.5s ease-in-out; }
.notification.show { bottom: 2rem; }
.notification.success { background-color: var(--status-success); }
.notification.error { background-color: var(--status-danger); }
.notification.info { background-color: var(--status-info); }
.notification.warning { background-color: var(--status-warning); }
.pagination { display: flex; justify-content: center; margin-top: 2rem; gap: 0.5rem; }
.pagination button { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 0; background-color: var(--bg-primary); color: var(--text-secondary); border: 1px solid var(--border-color); }
.pagination button.active { background-color: var(--primary-color); color: white; border-color: var(--primary-color); }
.loading { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255,255,255,0.7); z-index: 2000; justify-content: center; align-items: center; }
body.dark-mode .loading { background-color: rgba(17,24,39,0.7); }
.spinner { width: 50px; height: 50px; border: 4px solid var(--primary-color); border-bottom-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }
/* Adicione este código ao final do seu style.css */

/* Classe para ocultar elementos */
.hidden {
    display: none !important;
}

/* Estilos do Container de Autenticação */
#auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-secondary);
}

.login-card {
    background-color: var(--bg-primary);
    padding: 2.5rem;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.login-btn {
    margin-top: 1rem;
    width: 100%;
    justify-content: center;
}

.error-message {
    margin-top: 1rem;
    color: var(--status-danger);
    font-size: 0.875rem;
    min-height: 1.25rem; /* Evita que o layout pule */
}
/* --- ESTILO PARA O SELECT NA TABELA (NOVO) --- */

/* Esconde a seta padrão e as bordas do dropdown */
.table-status-select {
    -webkit-appearance: none;  /* Para Safari e Chrome */
    -moz-appearance: none;     /* Para Firefox */
    appearance: none;          /* Padrão */
    
    border: none;              /* Remove a borda */
    background-color: transparent; /* Faz o fundo ser o mesmo da classe de status */
    outline: none;             /* Remove a linha azul ao focar */
    cursor: pointer;           /* Mostra a "mãozinha" ao passar o mouse */
    
    /* Ajustes para alinhar o texto como antes */
    width: 100%;               /* Faz o select ocupar toda a célula */
    text-align: center;        /* Centraliza o texto do status */
    font-size: inherit;        /* Garante que o tamanho da fonte seja o mesmo do resto da tabela */
    padding-right: 5px;        /* Adiciona um pequeno espaço para não cortar o texto */
}

/* Opcional: Para o Firefox, que às vezes precisa de uma ajuda extra */
.table-status-select::-ms-expand {
    display: none;
}
/* --- ESTILOS PARA O FILTRO DE STATUS COM PILLS (NOVO) --- */

.filter-pills-container {
    display: flex;
    flex-wrap: wrap; /* Permite que os botões quebrem para a próxima linha */
    gap: 8px;      /* Espaçamento entre os botões */
    padding-top: 5px;
}

.filter-pill {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    -webkit-user-select: none; /* Impede a seleção de texto */
    user-select: none;
}

/* Estilo para o pill quando HOVER (mouse em cima) */
.filter-pill:hover {
    border-color: #999;
    background-color: #e0e0e0;
}

/* Estilo para o pill quando ATIVO (selecionado) */
.filter-pill.active {
    background-color: #007bff; /* Cor primária do seu tema */
    color: #fff;
    border-color: #007bff;
    font-weight: bold;
}

/* Estilo para o pill ATIVO no modo escuro */
.dark-mode .filter-pill.active {
    background-color: #4a90e2; /* Um azul um pouco mais claro para contraste */
    border-color: #4a90e2;
}

/* Estilo para o pill NÃO ATIVO no modo escuro */
.dark-mode .filter-pill {
    background-color: #444;


.attachment-field {
  /* Não precisa de estilos específicos agora */
}

/* Container para o nosso botão de upload customizado */
.custom-file-upload {
  display: flex;
  align-items: center; 
  gap: 10px;          
}

/* Estilo para o texto que mostra o nome do arquivo selecionado */
.file-name {
  font-size: 0.85em;
  color: #666; 
  white-space: nowrap; 
  overflow: hidden;    
  text-overflow: ellipsis; 
  max-width: 160px; 
}

/* Ajuste de cor para o modo escuro */
body.dark-mode .file-name {
  color: #bbb;
}

/* Opcional: faz o label que funciona como botão ter um cursor de ponteiro */
.custom-file-upload label {
    cursor: pointer;
}

/* style.css */
.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary-color);
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.75s linear infinite;
}

/* --- Estilos para o Painel de Pré-visualização (Modal) --- */

.loading-bar {
    width: 100%;
    height: 4px;
    background-color: color-mix(in srgb, var(--primary-color) 20%, transparent);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loading-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 2px;
    animation: loading-animation 1.5s infinite;
}

@keyframes loading-animation {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

/* Garante que a mensagem de erro no modal seja visível */
.modal-body .table-view .error-message {
    color: var(--status-danger);
    text-align: center;
    font-style: italic;
}

/* ONDE: style.css */
/* AÇÃO: Substitua TODAS as regras para #previewModal por este bloco. */

/* =================================================================== */
/* --- Layout Robusto para a Tabela de Pré-visualização (table-layout) --- */
/* =================================================================== */

#previewModal .table-view table {
    table-layout: fixed; /* Força as colunas a obedecerem as larguras */
    width: 100%;
    border-collapse: collapse;
}

#previewModal .table-view th,
#previewModal .table-view td {
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    white-space: nowrap;     /* Impede que o texto quebre linha */
    overflow: hidden;        /* Esconde o que transborda */
    text-overflow: ellipsis; /* Adiciona "..." */
    vertical-align: middle;
}

/* --- Controle preciso das colunas --- */

/* Coluna 1 (CNPJ) */
#previewModal .table-view th:nth-child(1),
#previewModal .table-view td:nth-child(1) {
    width: 28%;
}

/* Coluna 2 (EC) */
#previewModal .table-view th:nth-child(2),
#previewModal .table-view td:nth-child(2) {
    /* Esta coluna é a mais provável a ser cortada, o que é o desejado */
    width: 34%; 
}

/* Coluna 3 (Status) */
#previewModal .table-view th:nth-child(3),
#previewModal .table-view td:nth-child(3) {
    width: 18%;
    text-align: center;
}

/* Coluna 4 (Valor) */
#previewModal .table-view th:nth-child(4),
#previewModal .table-view td:nth-child(4) {
    width: 20%;
    text-align: right;
}


/* --- Estilo para o Ícone de Detalhes --- */
.preview-details-icon {
    cursor: pointer;
    margin-right: 0.5rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    transition: color 0.2s;
    display: inline-block;
    vertical-align: middle;
}

.preview-details-icon:hover {
    color: var(--primary-color);
}

.preview-details-icon-placeholder {
    display: inline-block;
    width: 28px;
}
