/* ============================================
   COFECI Design System (CFX)
   by Fábio Dias
   ============================================ */

/* ===========================================
   0. VARIÁVEIS (Design Tokens)
   =========================================== */
:root {
    /* Primary */
    --cfx-primary: #003D6B;
    --cfx-primary-light: #005491;
    --cfx-primary-hover: #004273;

    /* Accent (laranja institucional) */
    --cfx-accent: #E0922E;
    --cfx-accent-light: #fff3e0;

    /* Semantic */
    --cfx-error: #BA1A1A;

    /* Neutrals */
    --cfx-background: #f8f9ff;
    --cfx-surface: #ffffff;
    --cfx-surface-variant: #dee3eb;
    --cfx-outline: #727781;
    --cfx-outline-variant: #c1c7d1;
    --cfx-text-primary: #171c22;
    --cfx-text-secondary: #414750;

    /* Spacing & Borders */
    --cfx-radius-sm: 4px;
    --cfx-radius-md: 8px;
    --cfx-radius-lg: 12px;
    --cfx-transition: all 0.2s ease;
}


/* ===========================================
   1. BOTÕES
   =========================================== */

/* --- Base --- */
.cfx-btn {
    padding: 12px 24px;
    border-radius: var(--cfx-radius-md);
    font-family: "Public Sans", sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--cfx-transition);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    line-height: 1.5;
}

/* --- Primary (azul) --- */
.cfx-btn-primary {
    background-color: var(--cfx-primary-light);
    color: #ffffff;
}

.cfx-btn:hover,
.cfx-btn:focus {
    text-decoration: none;
}

.cfx-btn-primary:hover,
.cfx-btn-primary:focus {
    background-color: var(--cfx-primary-hover);
    color: #ffffff;
}

/* --- Secondary (outlined) --- */
.cfx-btn-secondary {
    background: transparent;
    border: 1px solid var(--cfx-outline-variant);
    color: var(--cfx-primary-light);
}

.cfx-btn-secondary:hover,
.cfx-btn-secondary:focus {
    background-color: var(--cfx-background);
    color: var(--cfx-primary-light);
}

/* --- Ghost (Voltar — neutro outline) --- */
.cfx-btn-ghost {
    background: transparent;
    border: 1px solid var(--cfx-outline-variant);
    color: var(--cfx-text-secondary);
}

.cfx-btn-ghost:hover,
.cfx-btn-ghost:focus {
    background-color: var(--cfx-background);
    color: var(--cfx-text-primary);
    border-color: var(--cfx-outline);
}

/* --- Danger (Sair — vermelho outline) --- */
.cfx-btn-danger {
    background: transparent;
    border: 1px solid var(--cfx-error);
    color: var(--cfx-error);
}

.cfx-btn-danger:hover,
.cfx-btn-danger:focus {
    background-color: rgba(186, 26, 26, 0.06);
    color: var(--cfx-error);
}

/* --- Small --- */
.cfx-btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

/* --- Disabled --- */
.cfx-btn:disabled,
.cfx-btn.cfx-btn-disabled {
    background-color: var(--cfx-surface-variant);
    color: var(--cfx-outline);
    cursor: not-allowed;
    opacity: 0.6;
    border: none;
}

.cfx-btn:disabled:hover,
.cfx-btn.cfx-btn-disabled:hover {
    background-color: var(--cfx-surface-variant);
    color: var(--cfx-outline);
}

/* --- Loading state --- */
.cfx-btn.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

.cfx-btn .btn-loading-text {
    display: none;
}

.cfx-btn.is-loading .btn-default-text {
    display: none;
}

.cfx-btn.is-loading .btn-loading-text {
    display: inline-block;
}

.cfx-btn .bi-arrow-repeat {
    display: inline-block;
    animation: cfx-spin 1s linear infinite;
}

@keyframes cfx-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===========================================
   2. FORMULÁRIOS
   =========================================== */

/* --- Campo container --- */
.cfx-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

/* --- Label --- */
.cfx-field label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--cfx-text-secondary);
    transition: var(--cfx-transition);
}

/* --- Input & Select (Default) --- */
.cfx-input,
.cfx-select {
    width: 100%;
    padding: 12px 16px;
    background-color: #f1f4f9;
    border: none;
    border-bottom: 2px solid var(--cfx-outline-variant);
    font-family: inherit;
    font-size: 14px;
    color: var(--cfx-text-primary);
    transition: var(--cfx-transition);
}

/* --- Disabled --- */
.cfx-input:disabled,
.cfx-select:disabled {
    background-color: var(--cfx-surface-variant);
    color: var(--cfx-outline);
    cursor: not-allowed;
    opacity: 0.7;
    border-bottom-color: transparent;
}

/* --- Active (focus) --- */
.cfx-input:focus,
.cfx-select:focus {
    outline: none;
    border-bottom-color: var(--cfx-primary-light);
    background-color: #ebf1f8;
}

.cfx-field:focus-within label {
    color: var(--cfx-primary-light);
}

/* --- Error state --- */
.cfx-field.cfx-field-error label {
    color: var(--cfx-error);
}

.cfx-field.cfx-field-error .cfx-input,
.cfx-field.cfx-field-error .cfx-select {
    background-color: rgba(186, 26, 26, 0.05);
    border-bottom-color: var(--cfx-error);
}

/* --- Ícone de erro (só aparece no estado error) --- */
.cfx-field .cfx-error-icon {
    display: none;
    position: absolute;
    right: 12px;
    top: 38px;
    color: var(--cfx-error);
    font-size: 20px;
}

.cfx-field.cfx-field-error .cfx-error-icon {
    display: block;
}

/* --- Mensagem de erro do validator --- */
.cfx-field .cfx-field-msg {
    font-size: 11px;
    color: var(--cfx-error);
    font-weight: 600;
}


/* ===========================================
   3. CHECKBOX
   =========================================== */

.cfx-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--cfx-text-primary);
    cursor: pointer;
}

.cfx-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--cfx-primary-light);
    margin: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.cfx-checkbox input[type="checkbox"]:checked {
    animation: cfx-check-pop 0.3s ease;
}

@keyframes cfx-check-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.cfx-checkbox label {
    font-size: 14px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    color: var(--cfx-text-primary);
    cursor: pointer;
    margin: 0;
}


/* ===========================================
   3.1. RADIO BUTTON
   =========================================== */

.cfx-radio {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--cfx-text-primary);
    cursor: pointer;
}

.cfx-radio input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--cfx-primary-light);
    margin: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.cfx-radio input[type="radio"]:checked {
    animation: cfx-check-pop 0.3s ease;
}

.cfx-radio label {
    font-size: 14px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    color: var(--cfx-text-primary);
    cursor: pointer;
    margin: 0;
}

/* --- Radio group (vertical) --- */
.cfx-radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --- Radio group (horizontal) --- */
.cfx-radio-group-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

/* ===========================================
   4. BANNERS (Status Feedback)
   =========================================== */

/* --- Base --- */
.cfx-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-radius: var(--cfx-radius-md);
    border-left: 4px solid transparent;
    background: var(--cfx-surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    animation: cfx-slideIn 0.3s ease-out;
    margin-bottom: 16px;
}

.cfx-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.cfx-banner-icon {
    font-size: 24px;
}

.cfx-banner-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 2px;
}

.cfx-banner-text {
    font-size: 13px;
    color: var(--cfx-text-secondary);
}

.cfx-banner-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--cfx-outline);
    padding: 4px;
    font-size: 20px;
    transition: var(--cfx-transition);
}

.cfx-banner-close:hover {
    color: var(--cfx-text-primary);
}

/* --- Success (verde) --- */
.cfx-banner-success {
    border-left-color: #006E27;
}

.cfx-banner-success .cfx-banner-icon {
    color: #006E27;
}

/* --- Warning (dourado) --- */
.cfx-banner-warning {
    border-left-color: var(--cfx-primary-light);
}

.cfx-banner-warning .cfx-banner-icon {
    color: var(--cfx-primary-light);
}

/* --- Danger (vermelho) --- */
.cfx-banner-danger {
    border-left-color: var(--cfx-error);
    background-color: #ffdad6;
}

.cfx-banner-danger .cfx-banner-icon {
    color: var(--cfx-error);
}

.cfx-banner-danger .cfx-banner-title,
.cfx-banner-danger .cfx-banner-text {
    color: #93000a;
}

/* --- Info (azul) --- */
.cfx-banner-info {
    border-left-color: var(--cfx-primary-light);
    background-color: #e8edf9;
}

.cfx-banner-info .cfx-banner-icon {
    color: var(--cfx-primary-light);
}

/* ===========================================
   5. CARD (Container de formulário)
   =========================================== */

.cfx-card {
    background-color: var(--cfx-surface);
    border-radius: var(--cfx-radius-lg);
    box-shadow: 0 1px 3px rgba(23, 28, 34, 0.05);
    padding: 40px;
}


/* ===========================================
   6. INFO CARD (Painel informativo)
   =========================================== */

.cfx-info-card {
    background-color: #f0f4fd;
    border-radius: var(--cfx-radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.cfx-info-card-body {
    display: flex;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.cfx-info-card-icon {
    flex-shrink: 0;
    font-size: 28px;
    color: var(--cfx-primary);
}

.cfx-info-card-title {
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--cfx-primary);
    margin-bottom: 12px;
}

.cfx-info-card-content {
    color: var(--cfx-text-secondary);
    font-size: 14px;
    line-height: 1.7;
    text-align: justify;
}


/* ===========================================
   7. SELECTION CARD (Cards de seleção)
   =========================================== */

/* --- Título da seleção --- */
.cfx-selection-title {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--cfx-text-primary);
    margin-bottom: 16px;
}

.cfx-selection-subtitle {
    font-size: 1.125rem;
    color: var(--cfx-text-secondary);
    max-width: 600px;
    margin: 0 auto 48px auto;
    line-height: 1.6;
}

/* --- Card --- */
.cfx-selection-card {
    background-color: var(--cfx-surface);
    border: 1px solid var(--cfx-outline-variant);
    border-radius: 24px;
    padding: 24px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: flex-start;
    gap: 20px;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}

.cfx-selection-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.1);
    border-color: transparent;
    text-decoration: none;
    color: inherit;
}

/* --- Barra lateral colorida --- */
.cfx-selection-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 6px;
    height: 100%;
    transition: width 0.3s ease, opacity 0.3s ease;
}

.cfx-selection-card-pf::before {
    background-color: var(--cfx-primary);
}

.cfx-selection-card-pj::before {
    background-color: #006E27;
}

.cfx-selection-card:hover::before {
    width: 100%;
    opacity: 0.05;
}

/* --- Ícone --- */
.cfx-selection-card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--cfx-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 2rem;
}

.cfx-selection-card-pf .cfx-selection-card-icon {
    background-color: #e0f2fe;
    color: var(--cfx-primary);
}

.cfx-selection-card-pj .cfx-selection-card-icon {
    background-color: #dcfce7;
    color: #006E27;
}


/* --- Conteúdo --- */
.cfx-selection-card-content {
    flex: 1;
}

.cfx-selection-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.cfx-selection-card-pf .cfx-selection-card-title {
    color: var(--cfx-primary);
}

.cfx-selection-card-pj .cfx-selection-card-title {
    color: #006E27;
}

.cfx-selection-card-desc {
    font-size: 0.875rem;
    color: var(--cfx-text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

/* --- Footer (link) --- */
.cfx-selection-card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 700;
    transition: gap 0.2s;
}

.cfx-selection-card-pf .cfx-selection-card-footer {
    color: var(--cfx-primary);
}

.cfx-selection-card-pj .cfx-selection-card-footer {
    color: #006E27;
}

.cfx-selection-card:hover .cfx-selection-card-footer {
    gap: 12px;
}

/* --- Responsivo --- */
@media (max-width: 576px) {
    .cfx-selection-title {
        font-size: 1.75rem;
    }

    .cfx-selection-subtitle {
        font-size: 1rem;
        margin-bottom: 32px;
    }

    .cfx-selection-card {
        padding: 20px;
    }
}


/* ===========================================
   8. PAGE HEADER (Título da página)
   =========================================== */

.cfx-page-header {
    position: relative;
    padding-left: 20px;
    margin-bottom: 40px;
}

.cfx-page-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--cfx-primary);
    border-radius: 4px;
}

.cfx-page-header-title {
    font-family: "Public Sans", sans-serif;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--cfx-text-primary);
    margin: 0;
    line-height: 1.2;
}

.cfx-page-header-subtitle {
    font-size: 1.1rem;
    color: var(--cfx-text-secondary);
    margin: 4px 0 0 0;
}

@media (max-width: 576px) {
    .cfx-page-header-title {
        font-size: 1.5rem;
    }

    .cfx-page-header-subtitle {
        font-size: 1rem;
    }
}


@keyframes cfx-slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ===========================================
   9. UTILITÁRIOS
   =========================================== */

/* --- Cor accent (laranja) --- */
.cfx-text-accent {
    color: var(--cfx-accent);
}

/* --- Label standalone (fora de cfx-field) --- */
.cfx-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--cfx-text-secondary);
}

/* --- Banner variantes de layout --- */
.cfx-banner-block {
    display: block;
}

.cfx-banner-content-top {
    align-items: flex-start;
}


/* --- Responsivo --- */
@media (max-width: 576px) {
    .cfx-btn {
        width: 100%;
        margin-bottom: 8px;
    }
}


/* ===========================================
   10. TABELA
   =========================================== */

/*
   Tokens locais de cor — para criar variações basta redefinir
   essas variáveis no seletor desejado. Exemplo:
     .cfx-table-success { --cfx-table-header-bg: #006E27; }
*/
.cfx-table {
    --cfx-table-header-bg:        var(--cfx-primary);
    --cfx-table-header-color:     #ffffff;
    --cfx-table-stripe-bg:        #f0f4fd;
    --cfx-table-hover-bg:         #e4ecf8;
    --cfx-table-border:           var(--cfx-outline-variant);
    --cfx-table-row-bg:           var(--cfx-surface);
    --cfx-table-text:             var(--cfx-text-primary);
    --cfx-table-text-secondary:   var(--cfx-text-secondary);
    --cfx-table-accent:           var(--cfx-primary-light);
}

.cfx-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: "Public Sans", sans-serif;
    font-size: 14px;
    color: var(--cfx-table-text);
    border-radius: var(--cfx-radius-md);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 61, 107, 0.08);
}

/* --- Header --- */
.cfx-table thead tr {
    background-color: var(--cfx-table-header-bg);
}

.cfx-table thead th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--cfx-table-header-color);
    white-space: nowrap;
    border-bottom: none;
}

.cfx-table thead th:first-child { border-radius: var(--cfx-radius-md) 0 0 0; }
.cfx-table thead th:last-child  { border-radius: 0 var(--cfx-radius-md) 0 0; }

/* --- Body --- */
.cfx-table tbody tr {
    background-color: var(--cfx-table-row-bg);
    transition: background-color 0.15s ease;
}

.cfx-table tbody tr:nth-child(even) {
    background-color: var(--cfx-table-stripe-bg);
}

.cfx-table tbody tr:hover {
    background-color: var(--cfx-table-hover-bg);
}

.cfx-table tbody td {
    padding: 13px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--cfx-table-border);
}

.cfx-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Footer --- */
.cfx-table tfoot td {
    padding: 12px 16px;
    font-size: 12px;
    color: var(--cfx-table-text-secondary);
    background-color: var(--cfx-table-stripe-bg);
    border-top: 2px solid var(--cfx-table-border);
}

/* --- Wrapper (scroll horizontal em telas pequenas) --- */
.cfx-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--cfx-radius-md);
}

/* --- Linha em destaque --- */
.cfx-table tbody tr.cfx-table-row-highlight {
    background-color: #e8f0fb !important;
}

.cfx-table tbody tr.cfx-table-row-highlight td:first-child {
    border-left: 3px solid var(--cfx-table-accent);
    padding-left: 13px;
}


/* ===========================================
   10.1. TABELA RESPONSIVA — modo card no mobile
   Modificador: .cfx-table-card-mobile
   Desktop: exibição de tabela normal
   Mobile (<576px): cada linha vira um card
   Requisito: adicionar data-label="Nome da coluna" em cada <td>
   =========================================== */

@media (max-width: 576px) {
    .cfx-table-card-mobile,
    .cfx-table-card-mobile thead,
    .cfx-table-card-mobile tbody,
    .cfx-table-card-mobile th,
    .cfx-table-card-mobile td,
    .cfx-table-card-mobile tr {
        display: block;
    }

    /* Esconde o cabeçalho — os labels aparecem via data-label */
    .cfx-table-card-mobile thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .cfx-table-card-mobile tbody tr {
        background-color: var(--cfx-surface);
        border: 1px solid var(--cfx-table-border);
        border-radius: var(--cfx-radius-md);
        margin-bottom: 12px;
        overflow: hidden;
        box-shadow: 0 1px 4px rgba(0, 61, 107, 0.07);
    }

    /* Remove zebra — todos os cards ficam brancos */
    .cfx-table-card-mobile tbody tr:nth-child(even) {
        background-color: var(--cfx-surface);
    }

    .cfx-table-card-mobile tbody tr:hover {
        background-color: var(--cfx-table-hover-bg);
    }

    .cfx-table-card-mobile tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 16px;
        border-bottom: 1px solid var(--cfx-table-border);
        font-size: 13px;
        gap: 12px;
    }

    .cfx-table-card-mobile tbody td:last-child {
        border-bottom: none;
    }

    /* Label automático via data-label */
    .cfx-table-card-mobile tbody td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--cfx-table-text-secondary);
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Primeira célula vira cabeçalho do card (fundo azul) */
    .cfx-table-card-mobile tbody td:first-child {
        background-color: var(--cfx-table-header-bg);
        color: var(--cfx-table-header-color);
        font-weight: 700;
        font-size: 14px;
        justify-content: flex-start;
    }

    .cfx-table-card-mobile tbody td:first-child::before {
        display: none;
    }

    /* Linha destaque — remove borda lateral (não faz sentido em card) */
    .cfx-table-card-mobile tbody tr.cfx-table-row-highlight td:first-child {
        border-left: none;
        padding-left: 16px;
    }
}
