/* ============================================= */
/* MÓDULO DE CADASTROS E TABELAS (cadastros.css) */
/* (Clientes, Usuários, Consórcios e AgroEasy)   */
/* ============================================= */

/* --- SEÇÃO USUÁRIOS (IDÊNTICO AO ORIGINAL) --- */
.users-section { background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0px 2px 5px rgba(0,0,0,0.1); margin-bottom: 20px; }
.users-section h2 { font-size: 20px; margin-bottom: 15px; }
.users-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.users-table th, .users-table td { border: 1px solid #ddd; padding: 10px; text-align: left; }
.users-table th { background: #f4f4f4; }
#register-user-section { background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0px 2px 5px rgba(0,0,0,0.1); }
#register-user-section h2 { font-size: 20px; margin-bottom: 15px; }
#register-user-section .form-group { margin-bottom: 12px; }
#register-user-section label { font-weight: bold; display: block; margin-bottom: 5px; }
#register-user-section .form-control { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 6px; }

/* --- SEÇÃO CLIENTES E CONSÓRCIOS (IDÊNTICO AO ORIGINAL) --- */
.clients-section, .register-client-section { background: white; border-radius: 8px; padding: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.clients-section h2, .register-client-section h2 { margin-bottom: 15px; color: var(--azul); }
.clients-table { width: 100%; border-collapse: collapse; }
/* Aqui estava o erro: o padding original era 8px, e não 10px */
.clients-table th, .clients-table td { border: 1px solid #ddd; padding: 8px; text-align: center; }
.clients-table th { background: var(--azul); color: white; }
.clients-table td { background: #f9f9f9; }
.clients-table tr:hover td { background: var(--azulclaro); }

.clients-table .action-btn { padding: 5px 10px; border: none; border-radius: 4px; cursor: pointer; color: white; margin: 2px; }
.btn-cadastrar-cliente { background: var(--amarelo); color: var(--azul); font-weight: bold; border: none; padding: 10px 20px; cursor: pointer; border-radius: 4px; font-size: 1em; transition: all 0.3s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn-cadastrar-cliente:hover { background: #f7df2e; transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }

.clients-table .btn-new-sale { background: var(--azul); font-weight: bold; }
.clients-table .btn-edit { background: var(--amarelo); color: var(--azul); font-weight: bold; }
.clients-table .btn-delete { background: var(--vermelho); font-weight: bold; }
.clients-table .btn-detalhes { background: var(--verde); font-weight: bold; }
.clients-table .btn-reset { background: var(--azul); color: white; font-weight: bold; }

#client-form .form-group { margin-bottom: 15px; }
#client-form label { display: block; margin-bottom: 5px; font-weight: 500; }
#client-form .form-control { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; }
#client-form .btn-pay { background: var(--verde); color: white; border: none; margin-top: 10px; padding: 8px 16px; cursor: pointer; border-radius: 4px; font-size: 1em; font-weight: bold; }

.btn-cancel { background: var(--amarelo); color: var(--azul); border: none; cursor: pointer; border-radius: 4px; font-size: 1em; margin-top: 10px; padding: 8px 16px; font-weight: bold; }
#cad_clientes .btn-cancel { background: var(--vermelho) !important; color: white !important; }

.checkbox-group ul { list-style-type: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.checkbox-group li { margin: 5px 0; }
.checkbox-whats ul { list-style-type: none; padding: 0; display: grid; grid-template-columns: repeat(1, 1fr); gap: 10px; }
.checkbox-whats li { margin: 40px 0; }
#client-whatsapp-checkbox { transform: scale(1.2); margin-right: 10px; }

.produtos-interesse { margin-top: 10px; }
#add-consorcio-btn { margin-top: 10px; background: var(--azul); color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: bold; }
#add-consorcio-btn.disabled { background-color: #d3d3d3; cursor: not-allowed; color: #808080; }
.consorcio { border: 1px solid #ddd; padding: 10px; margin-top: 10px; }

#clients-list td:nth-child(2), #clients-list td:nth-child(3), #clients-list td:nth-child(4) { text-align: center; }

.btn-delete-consorcio { background: var(--vermelho); color: white; font-weight: bold; padding: 5px 10px; border: none; border-radius: 4px; cursor: pointer; }
.btn-edit-consorcio { background: var(--amarelo); color: var(--azul); font-weight: bold; padding: 5px 10px; border: none; border-radius: 4px; cursor: pointer; margin-right: 5px; }

.btn-group { 
    display: flex; 
    gap: 5px; 
    align-items: center; 
    justify-content: center; 
    min-height: 75px; 
    flex-wrap: nowrap !important; /* Impede que os botões pulem de linha */
}

/* --- ADICIONE ESTA NOVA REGRA LOGO ABAIXO PARA BLINDAR A COLUNA --- */
.clients-table td:has(.btn-group),
.clients-table td:has(.badge-agro) {
    white-space: nowrap !important; /* Impede a tabela de espremer o texto/botões */
}

#consorcios-list td { vertical-align: middle; text-align: center; }

input.form-control-disabled { background-color: #e9ecef; opacity: 1; cursor: not-allowed; color: #495057; }

/* --- TELA DE NOVA VENDA --- */
.nova-venda-cliente-selecao { display: flex; gap: 20px; margin-bottom: 20px; align-items: flex-start; }
.search-column { flex: 1; position: relative; }
.selected-column { flex: 1; }
.input-with-button { display: flex; gap: 10px; }
.input-with-button input { flex-grow: 1; }
.search-results-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; background-color: white; border: 1px solid #ddd; border-top: none; max-height: 200px; overflow-y: auto; z-index: 100; box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.search-result-item { padding: 10px; cursor: pointer; }
.search-result-item:hover { background-color: #f1f1f1; }
.search-result-item.none { cursor: default; color: #888; }
#add_vendas #search-cliente-venda { flex-basis: 70%; }
#add_vendas .btn-cadastrar-cliente { flex-basis: 30%; white-space: nowrap; }

/* --- ESTILOS AGROEASY (ORIGINAIS) --- */
.badge-agro { display: inline-block; padding: 4px 8px; border-radius: 12px; font-size: 0.85em; font-weight: bold; color: white; }
.badge-agro-finalizado { background-color: var(--verde); }
.badge-agro-parcial { background-color: var(--laranja); }
.badge-agro-aguardando { background-color: var(--cinza); color: #555; }

/*.btn-plus-parcela { background: var(--verde); color: white; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; margin-left: 8px; font-weight: bold; line-height: 1; }*/

.btn-plus-parcela {
    background: var(--verde);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    margin-left: 8px;
    font-weight: bold;
    
    /* Centralização à prova de balas */
    display: inline-flex !important; 
    align-items: center; 
    justify-content: center; 
    padding: 0;
    
    /* A MÁGICA: Zera a altura da linha e usa um pequeno padding para empurrar o "+" para baixo */
    line-height: 0 !important; 
    font-size: 18px; 
    padding-bottom: 4px; /* Esse é o ajuste fino que força o + pro meio */
}

.btn-plus-parcela:hover { background: var(--verdeescuro); }
.agro-alert-row { background-color: #fff3e0; border-left: 4px solid #d32f2f; }
.doc-item-view { padding: 8px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.doc-item-view a { text-decoration: none; font-weight: bold; }
.doc-item-view button { padding: 2px 8px; font-size: 0.8em; }

/* --- CORES DE STATUS --- */
.status-lead { font-weight: bold; color: #2381F3; } 
.status-em-contato { font-weight: bold; color: #15E24D; } 
.status-reunião-agendada { font-weight: bold; color: var(--azul); } 
.status-proposta-gerada { font-weight: bold; color: var(--verdeescuro); } 
.status-negociacão { font-weight: bold; color: var(--laranja); } 
.status-não-fechou { font-weight: bold; color: var(--grafite); } 
.status-venda-realizada { font-weight: bold; color: var(--verde); } 
.status-consórcio-pausado { font-weight: bold; color: var(--pink); } 
.status-consórcio-inadimplente { font-weight: bold; color: var(--bordo-borda); } 
.status-consórcio-cancelado { font-weight: bold; color: var(--vermelho); } 
.status-consorcio-pendente { background: var(--amareloclaro); color: var(--azul); border: 1px solid var(--laranja); font-weight: bold; }

/* --- RESPONSIVIDADE FORMS (Mobile) --- */
@media (max-width: 768px) {
    #cad_clientes .form-group:has(#client-name) > div[style*="display: flex"] { flex-wrap: wrap !important; row-gap: 15px !important; }
    #cad_clientes .form-group:has(#client-name) > div[style*="display: flex"] > div[style*="flex: 2"] { flex-basis: 100% !important; order: 1 !important; }
    #cad_clientes .form-group:has(#client-name) > div[style*="display: flex"] > div[style*="flex: 1"]:has(#client-cpf-cnpj) { flex-basis: calc(50% - 5px) !important; flex-grow: 1 !important; order: 2 !important; }
    #cad_clientes .form-group:has(#client-name) > div[style*="display: flex"] > div[style*="flex: 1"]:has(#client-status-manual) { flex-basis: calc(50% - 5px) !important; flex-grow: 1 !important; order: 3 !important; }

    #cad_clientes .form-group:has(#client-address) > div[style*="display: flex"] { flex-wrap: wrap !important; row-gap: 15px !important; }
    #cad_clientes .form-group:has(#client-address) > div[style*="display: flex"] > div[style*="flex: 3"] { flex-basis: 100% !important; order: 1 !important; }
    #cad_clientes .form-group:has(#client-address) > div[style*="display: flex"] > div[style*="flex: 2"] { flex-basis: calc(50% - 5px) !important; flex-grow: 1 !important; order: 2 !important; }
    #cad_clientes .form-group:has(#client-address) > div[style*="display: flex"] > div[style*="flex: 1"] { flex-basis: calc(50% - 5px) !important; flex-grow: 1 !important; order: 3 !important; }

    #cad_clientes .form-group:has(#client-birthday) > div[style*="display: flex"] { flex-wrap: wrap !important; row-gap: 15px !important; }
    #cad_clientes .form-group:has(#client-birthday) > div[style*="display: flex"] > div:nth-child(1) { flex-basis: 100% !important; order: 1 !important; }
    #cad_clientes .form-group:has(#client-birthday) > div[style*="display: flex"] > div:nth-child(2) { flex-basis: 100% !important; flex: 1 1 100% !important; order: 2 !important; }
    #cad_clientes .form-group:has(#client-birthday) > div[style*="display: flex"] > div:nth-child(3) { flex-basis: calc(50% - 5px) !important; flex-grow: 1 !important; order: 3 !important; }
    #cad_clientes .form-group:has(#client-birthday) > div[style*="display: flex"] > div:nth-child(4) { flex-basis: calc(50% - 5px) !important; flex-grow: 1 !important; order: 4 !important; }

    #cad_clientes .form-group:has(#add-consorcio-btn) { display: flex !important; flex-wrap: wrap !important; justify-content: center !important; gap: 15px; margin-top: 30px !important; }
    #cad_clientes .form-group:has(#add-consorcio-btn) > #add-consorcio-btn { flex-basis: 100% !important; max-width: 300px !important; margin: 0 !important; float: none !important; order: 1 !important; }
    #cad_clientes .form-group:has(#add-consorcio-btn) > .btn-pay { flex-basis: calc(50% - 7.5px) !important; flex-grow: 1 !important; max-width: 200px !important; margin: 0 !important; float: none !important; order: 3 !important; }
    #cad_clientes .form-group:has(#add-consorcio-btn) > .btn-cancel { flex-basis: calc(50% - 7.5px) !important; flex-grow: 1 !important; max-width: 200px !important; margin: 0 !important; float: none !important; order: 2 !important; background: var(--vermelho) !important; color: white !important; }

    #cad_usuarios .form-row-flex:has(#user-name) { flex-wrap: wrap !important; row-gap: 15px !important; }
    #cad_usuarios .form-row-flex:has(#user-name) > .form-group { flex-basis: 100% !important; flex: 1 1 100% !important; }
    #cad_usuarios .form-row-flex:has(#user-password) { flex-wrap: wrap !important; row-gap: 15px !important; }
    #cad_usuarios .form-row-flex:has(#user-password) > .form-group:has(#user-password), 
    #cad_usuarios .form-row-flex:has(#user-password) > #confirm-password-group, 
    #cad_usuarios .form-row-flex:has(#user-password) > #user-type-container, 
    #cad_usuarios .form-row-flex:has(#user-password) > #user-tabela-container { flex-basis: calc(50% - 10px) !important; flex-grow: 1 !important; }
    #cad_usuarios .form-row-flex:has(#user-address) { flex-wrap: wrap !important; row-gap: 15px !important; }
    #cad_usuarios .form-row-flex:has(#user-address) > .form-group { flex-basis: 100% !important; flex: 1 1 100% !important; }
    #cad_usuarios .form-row-flex:has(#user-dados-bancarios) { flex-wrap: wrap !important; row-gap: 15px !important; }
    #cad_usuarios .form-row-flex:has(#user-dados-bancarios) > .form-group { flex-basis: 100% !important; flex: 1 1 100% !important; }
}