/* V360 Clube - Estilos */
:root {
    --v360-primary: #0d6efd;
    --v360-dark: #1a1d21;
    --v360-success: #198754;
    --v360-warning: #ffc107;
    --v360-danger: #dc3545;
    --v360-info: #0dcaf0;
    --v360-surface: #ffffff;
    --v360-border: #d9e1ea;
    --v360-text-muted: #5f6b78;
    --v360-focus: rgba(13, 110, 253, 0.18);
}

body {
    background-color: #f4f6f9;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    overflow-x: hidden;
}

.main-content {
    margin-top: 70px;
    padding: 20px;
    min-height: calc(100vh - 130px);
}

/* Estrutura visual base */
.card {
    border: 1px solid #e7edf4;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(17, 32, 51, 0.06);
}

.card-header {
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
}

.card-body {
    background: var(--v360-surface);
}

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1d21 0%, #2c3e50 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--v360-dark);
}

.login-logo {
    text-align: center;
    font-size: 3rem;
    color: var(--v360-info);
    margin-bottom: 10px;
}

/* Cards do Dashboard */
.stat-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-card .card-body {
    padding: 20px;
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

/* Tabelas */
.table-v360 {
    font-size: 13px;
}

.table-v360 th {
    background-color: var(--v360-dark);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-v360 td {
    vertical-align: middle;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* Opcional para casos que realmente precisam rolagem interna */
.table-wrapper.table-scroll-y {
    max-height: 70vh;
    overflow-y: auto;
}

/* Badges de Status */
.badge-pago { background-color: #198754; }
.badge-pendente { background-color: #dc3545; }
.badge-bonificacao { background-color: #0dcaf0; color: #000; }
.badge-nao-pagante { background-color: #6c757d; }
.badge-vazio { background-color: #e9ecef; color: #666; }
.badge-saiu { background-color: #343a40; }

/* Grid de Mensalidades */
.mensalidade-grid {
    overflow-x: auto;
}

.mensalidade-grid table {
    font-size: 12px;
}

.mensalidade-grid th,
.mensalidade-grid td {
    text-align: center;
    min-width: 35px;
    padding: 4px 6px !important;
}

.mensalidade-grid .nome-col {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 5;
    min-width: 200px;
    text-align: left;
}

.mensalidade-grid thead .nome-col {
    background: var(--v360-dark);
    z-index: 15;
}

.mes-cell {
    cursor: pointer;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 11px;
    transition: all 0.15s;
}

.mes-cell:hover {
    opacity: 0.85;
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 2;
    position: relative;
}

.mes-pago { background-color: #198754; color: #fff; }
.mes-pendente { background-color: #dc3545; color: #fff; }
.mes-bonificacao { background-color: #0dcaf0; color: #000; }
.mes-nao-pagante { background-color: #6c757d; color: #fff; }
.mes-vazio { background-color: #e9ecef; color: #999; }
.mes-saiu { background-color: #343a40; color: #fff; }

/* Filtros */
.filtro-bar {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

/* Formulários: mais legíveis sem quebrar os campos inline de tabela */
.form-label {
    margin-bottom: 0.3rem;
    font-weight: 600;
    color: #2b3642;
    letter-spacing: 0.01em;
}

.card .form-control.form-control-sm:not(.auto-save-field):not(.controle-autosave-field),
.card .form-select.form-select-sm:not(.auto-save-field):not(.controle-autosave-field),
.modal .form-control.form-control-sm,
.modal .form-select.form-select-sm,
.filtro-bar .form-control.form-control-sm,
.filtro-bar .form-select.form-select-sm {
    min-height: 38px;
    padding: 0.5rem 0.7rem;
    border-radius: 10px;
    border-color: var(--v360-border);
    background: #fff;
    color: #132033;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.card textarea.form-control.form-control-sm,
.modal textarea.form-control.form-control-sm {
    min-height: 84px;
}

.card .form-control.form-control-sm::placeholder,
.card .form-select.form-select-sm::placeholder,
.modal .form-control.form-control-sm::placeholder {
    color: var(--v360-text-muted);
}

.card .form-control.form-control-sm:not(.auto-save-field):not(.controle-autosave-field):focus,
.card .form-select.form-select-sm:not(.auto-save-field):not(.controle-autosave-field):focus,
.modal .form-control.form-control-sm:focus,
.modal .form-select.form-select-sm:focus,
.filtro-bar .form-control.form-control-sm:focus,
.filtro-bar .form-select.form-select-sm:focus {
    border-color: #7cb3ff;
    box-shadow: 0 0 0 4px var(--v360-focus);
}

.card .form-check-input {
    border-color: #b8c6d6;
}

.card .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--v360-focus);
}

.card .form-check-label,
.card small.text-muted,
.card .text-muted {
    color: var(--v360-text-muted) !important;
}

.card .btn {
    border-radius: 10px;
}

/* Mensalidades (modo simplificado): organização visual */
.mensalidades-simples-wrapper {
    overflow: auto;
    border: 1px solid #dbe4ef;
}

.mensalidades-simples-table {
    min-width: 1480px;
    font-size: 12.5px;
}

.mensalidades-simples-table thead th {
    padding: 10px 9px;
    font-size: 12px;
    letter-spacing: 0.02em;
}

.mens-col-associado { min-width: 220px; }
.mens-col-status { min-width: 170px; }
.mens-col-edicao { min-width: 560px; }
.mens-col-sicredi { min-width: 260px; }
.mens-col-fiscal { min-width: 250px; }
.mens-col-whats { min-width: 220px; }

.mensalidades-simples-table tbody td {
    padding: 10px 8px;
    vertical-align: top;
    background: #f8fbff;
}

.mensalidades-simples-table tbody tr:nth-child(even) td {
    background: #f4f8fd;
}

.mensalidades-simples-table tbody tr:hover td {
    background: #edf4fc;
}

.mens-panel {
    background: #fff;
    border: 1px solid #dce5f0;
    border-radius: 10px;
    padding: 9px;
    min-height: 100%;
}

.mens-associado-cod {
    color: #6b7988;
    font-size: 11px;
    font-weight: 600;
    display: block;
}

.mens-associado-nome {
    color: #1f2d3c;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    margin: 3px 0;
}

.mens-associado-tipo {
    color: #5e6b78;
    font-size: 11px;
}

.mens-status-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.mens-status-label {
    font-size: 12px;
    font-weight: 600;
    color: #213041;
}

.mens-inline-label {
    display: block;
    margin-bottom: 3px;
    color: #4a596a;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mens-edit-panel .auto-save-row {
    margin: 0;
}

.mens-edit-panel .auto-save-row > [class*="col-"] {
    padding-left: 4px;
    padding-right: 4px;
}

.mens-edit-panel .auto-save-field {
    min-height: 34px;
    border-radius: 8px;
    border-color: #c9d5e3;
    font-size: 12px;
    padding: 0.25rem 0.5rem;
}

.mens-edit-panel input[type="number"].auto-save-field {
    text-align: right;
}

.mens-edit-panel .auto-save-indicator {
    display: block;
    line-height: 1.25;
    padding-top: 6px;
}

.mens-integracao-panel .sicredi-box,
.mens-integracao-panel .fiscal-box {
    margin-top: 8px;
}

.mens-integracao-panel .btn,
.mens-whats-panel .btn {
    text-align: left;
}

.mens-info-line {
    font-size: 11px;
    line-height: 1.35;
}

/* EDA (exploratory view) */
.eda-kpi-card .card-body {
    padding: 14px 14px 12px;
}

.eda-kpi-card .stat-value {
    line-height: 1.1;
    margin-top: 2px;
}

.eda-insights {
    background: linear-gradient(135deg, #f8fbff 0%, #eef4fb 100%);
    border-color: #d3dfec !important;
    color: #243447;
    font-size: 13px;
}

.eda-list-table th {
    font-size: 11px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: #f1f5fa;
    color: #334455;
    border-top: 0;
}

.eda-list-table td {
    vertical-align: middle;
}

.eda-progress {
    height: 8px;
    border-radius: 999px;
    background: #e6eef7;
}

.eda-amostra-table td {
    vertical-align: middle;
}

.eda-public-kpi {
    border: 1px solid #dbe7f6;
    border-radius: 10px;
    padding: 10px 12px;
    background: linear-gradient(180deg, #f7fbff 0%, #eef5fd 100%);
    height: 100%;
}

.eda-public-kpi .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #4a6077;
}

.eda-public-kpi .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #163a5f;
    line-height: 1.2;
    margin-top: 3px;
}

.eda-public-kpi .meta {
    font-size: 11px;
    color: #607990;
}

.eda-wave-box {
    border: 1px solid #dce6f2;
    border-radius: 10px;
    background: #f9fbfe;
    padding: 10px;
    min-height: 98px;
}

.eda-wave-title {
    font-size: 12px;
    font-weight: 700;
    color: #23364b;
    margin-bottom: 7px;
}

.eda-wave-chip {
    display: inline-block;
    font-size: 11px;
    line-height: 1.3;
    margin: 0 4px 4px 0;
    padding: 4px 7px;
    border-radius: 999px;
    background: #e5eef9;
    color: #1f3f63;
    border: 1px solid #cfdeee;
}

.eda-case-lead {
    background: linear-gradient(180deg, #fbfdff 0%, #f1f6fd 100%);
    border-color: #d4e2f2 !important;
    color: #2a3f56;
    font-size: 13px;
}

.eda-case-score {
    border: 1px solid #d8e4f2;
    border-radius: 10px;
    background: #f9fbfe;
    padding: 10px 12px;
    height: 100%;
}

.eda-case-score-title {
    font-size: 12px;
    font-weight: 700;
    color: #243a52;
    margin-bottom: 8px;
}

.eda-case-score-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.eda-case-score-grid .label {
    font-size: 10px;
    text-transform: uppercase;
    color: #637a92;
    letter-spacing: 0.02em;
}

.eda-case-score-grid .value {
    font-size: 1.05rem;
    line-height: 1.1;
    color: #15395e;
}

/* Eventos */
.evento-card .card-header strong {
    font-size: 0.95rem;
}

.evento-descricao {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.evento-grid-container .evento-row {
    background: #f8fafc;
    border-color: #d8e1ec !important;
}

.evento-grid-container .form-label {
    color: #42566b;
}

.evento-modal-body {
    max-height: calc(100vh - 170px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Ações */
.btn-acao {
    padding: 2px 8px;
    font-size: 12px;
}

/* Modal */
.modal-header {
    background-color: var(--v360-dark);
    color: #fff;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* Trava o scroll da página quando um modal está aberto */
body.modal-open {
    overflow: hidden !important;
}

/* Impede scroll chaining: rolar dentro do modal não rola a página de baixo */
.modal,
.modal-body {
    overscroll-behavior: contain;
}

/*
 * Corrige modal-dialog-scrollable quando há um <form> entre .modal-content e .modal-body.
 * Sem isso o flexbox do Bootstrap não consegue calcular a altura do modal-body
 * e o scroll interno nunca é ativado.
 */
.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
.modal-dialog-scrollable .modal-body {
    min-height: 0;
}

/* Footer */
.footer {
    font-size: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 10px;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    .mensalidades-simples-table {
        min-width: 1280px;
    }

    .mens-edit-panel .auto-save-row > [class*="col-"] {
        padding-left: 3px;
        padding-right: 3px;
    }

    .eda-insights span {
        display: block;
        margin-left: 0 !important;
        margin-top: 4px;
    }

    .evento-modal-body {
        max-height: calc(100vh - 130px);
    }
}

/* Legenda de cores */
.legenda {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    padding: 10px 15px;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.05);
}

.legenda-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.legenda-cor {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    display: inline-block;
}

/* Busca */
.search-highlight {
    background-color: #fff3cd;
    font-weight: 600;
}

/* Autosave (modo simplificado mensalidades) */
.auto-save-indicator {
    display: inline-block;
    font-size: 12px;
}

.auto-save-indicator.pending {
    color: #6c757d;
}

.auto-save-indicator.saving {
    color: #0d6efd;
}

.auto-save-indicator.saved {
    color: #198754;
}

.auto-save-indicator.error {
    color: #dc3545;
    font-weight: 600;
}
