/**
 * Portal do Cliente - Estilos centralizados
 * Manutenção: altere aqui para refletir em todas as páginas do portal.
 */

/* ========== Variáveis ========== */
:root {
    --portal-bg: #f0f4f8;
    --portal-bg-inner: #f5f7fa;
    --portal-card: #fff;
    --portal-primary: #0d6efd;
    --portal-border: #dee2e6;
    --portal-text: #1a1a2e;
    --portal-muted: #6c757d;
}

/* ========== Base ========== */
* { box-sizing: border-box; }
body.portal-body {
    font-family: 'Inter', system-ui, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}
body.portal-body.portal-body-login { background: var(--portal-bg); }
body.portal-body.portal-body-app { background: var(--portal-bg-inner); }

/* ========== Login (index) ========== */
.portal-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.portal-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.portal-logo img {
    max-height: 90px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}
.portal-logo .logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--portal-text);
    margin-top: 0.5rem;
}
.portal-card {
    background: var(--portal-card);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--portal-border);
}
.portal-card h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--portal-text);
    margin-bottom: 0.5rem;
    text-align: center;
}
.portal-card .sub {
    font-size: 0.875rem;
    color: var(--portal-muted);
    text-align: center;
    margin-bottom: 1.5rem;
}
.portal-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--portal-muted);
}
.portal-voltar {
    font-size: 0.875rem;
    color: var(--portal-muted);
    margin-top: 1rem;
    text-align: center;
}
.portal-voltar a { color: var(--portal-primary); text-decoration: none; }
.portal-voltar a:hover { text-decoration: underline; }

/* Login: formulário */
.portal-card .form-control { border-radius: 8px; padding: 0.75rem 1rem; }
.portal-card .btn-ok {
    width: 100%;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    background: var(--portal-primary);
    border: none;
}
.portal-card .btn-ok:hover { background: #0b5ed7; color: #fff; }
.portal-card .input-group-text {
    border-radius: 0 8px 8px 0;
    background: #f8f9fa;
    border-left: 0;
}
.portal-card .input-group .form-control { border-right: 0; border-radius: 8px 0 0 8px; }
.portal-card .input-group:focus-within .form-control { box-shadow: none; border-color: #86b7fe; }
.portal-card .input-group:focus-within .input-group-text { border-color: #86b7fe; }

/* Toasts */
.toast-container-portal {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
}
.toast-portal {
    min-width: 320px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    border-radius: 10px;
    border: none;
}

/* ========== Header / Nav (área logada) ========== */
.portal-nav {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
@media (min-width: 576px) {
    .portal-nav { padding: 0.875rem 1.5rem; }
}
.portal-nav .navbar-brand {
    font-weight: 700;
    color: var(--portal-text);
    font-size: 0.9rem;
    letter-spacing: -0.02em;
}
@media (min-width: 576px) {
    .portal-nav .navbar-brand { font-size: 1rem; }
}
.portal-nav .navbar-brand img { max-height: 32px; width: auto; }
@media (min-width: 576px) {
    .portal-nav .navbar-brand img { max-height: 38px; }
}
.portal-user {
    font-size: 0.75rem;
    font-weight: 600;
    color: #495057;
    letter-spacing: 0.02em;
}
@media (min-width: 576px) {
    .portal-user { font-size: 0.8125rem; }
}
.portal-nav .nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
}
.portal-nav .nav-link:hover { color: var(--portal-primary); background: #f8f9fa; }
.portal-nav .nav-link.active { color: var(--portal-primary); font-weight: 600; }

/* ========== Container e conteúdo ========== */
.portal-container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
}
@media (min-width: 576px) {
    .portal-container { padding: 1.25rem 1.5rem; }
}
@media (min-width: 768px) {
    .portal-container { padding: 1.75rem 1.5rem; }
}
.portal-page-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--portal-text);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
@media (min-width: 576px) {
    .portal-page-title { font-size: 1.35rem; margin-bottom: 1.5rem; }
}

/* Cards de resumo */
.portal-cards-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
@media (min-width: 400px) {
    .portal-cards-row {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
        margin-bottom: 1.75rem;
    }
}
.portal-summary-card {
    background: #fff;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    border: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    gap: 1rem;
}
.portal-summary-card .icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(253, 126, 20, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.portal-summary-card .icon-wrap i { font-size: 1.5rem; color: #fd7e14; }
.portal-summary-card .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--portal-muted);
    margin-bottom: 0.15rem;
}
@media (min-width: 576px) {
    .portal-summary-card .label { font-size: 0.75rem; }
}
.portal-summary-card .value { font-size: 1.25rem; font-weight: 700; color: #fd7e14; }
@media (min-width: 576px) {
    .portal-summary-card .value { font-size: 1.5rem; }
}

/* Card de seção (mesma largura do card de resumo acima) */
.portal-card.portal-card-section {
    width: 100%;
    max-width: none;
    padding: 6px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e9ecef;
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.portal-card-header {
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 6px;
    margin: 0;
    border-bottom: 1px solid #e9ecef;
    background: #fafbfc;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
@media (min-width: 576px) {
    .portal-card-header { font-size: 1rem; padding: 6px; }
}
.portal-card-header .count { font-size: 0.8125rem; font-weight: 500; color: var(--portal-muted); }
.portal-pendentes-sub { font-size: 0.75rem; color: var(--portal-muted); font-weight: 400; margin-left: 0.25rem; }

/* Tabelas: sem scroll horizontal; conteúdo sempre cabe na tela */
.portal-table-responsive {
    width: 100%;
    min-width: 0;
    overflow-x: visible;
}
.table-portal {
    margin: 0;
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
}
/* Desktop (telas grandes): 5 colunas (Descrição, Vencimento, Valor/Pagamento, Status, Ação) */
@media (min-width: 1200px) {
    .table-portal th:nth-child(1),
    .table-portal td:nth-child(1) { width: 28%; }
    .table-portal th:nth-child(2),
    .table-portal td:nth-child(2) { width: 18%; min-width: 7rem; }
    .table-portal th:nth-child(3),
    .table-portal td:nth-child(3) { width: 18%; min-width: 7rem; }
    .table-portal th:nth-child(4),
    .table-portal td:nth-child(4) { width: 12%; }
    .table-portal th:nth-child(5),
    .table-portal td:nth-child(5) { width: 24%; }
}
.table-portal th {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--portal-muted);
    padding: 6px;
    border-bottom: 1px solid #e9ecef;
    background: #fafbfc;
}
@media (min-width: 576px) {
    .table-portal th { font-size: 0.75rem; padding: 6px; }
}
.table-portal td {
    padding: 6px;
    vertical-align: middle;
    font-size: 0.875rem;
    border-bottom: 1px solid #f1f3f5;
}
/* Descrição: formatação melhorada (quebra por palavra, legibilidade) */
.table-portal .td-descricao {
    overflow-wrap: break-word;
    word-break: normal;
    line-height: 1.4;
}
.table-portal .portal-descricao-texto {
    display: block;
    word-wrap: break-word;
}
/* Vencimento e Pagamento/Valor: data em uma linha */
.table-portal th:nth-child(2),
.table-portal td:nth-child(2),
.table-portal th:nth-child(3),
.table-portal td:nth-child(3) {
    white-space: nowrap;
}
@media (min-width: 576px) {
    .table-portal td { font-size: 0.9375rem; padding: 6px; }
}
.table-portal tbody tr:last-child td { border-bottom: 0; }
.table-portal tbody tr:hover { background: #f8f9fa; }
/* Valor sempre em uma linha (evita R$ e número quebrados) */
.table-portal .td-valor { white-space: nowrap; }
.table-portal .td-valor .valor-numero { white-space: nowrap; }

/* Tablet e mobile: tabela vira cards — label em cima, valor embaixo (evita texto cortado) */
@media (max-width: 1199px) {
    .table-portal thead { display: none; }
    .table-portal,
    .table-portal tbody,
    .table-portal tr,
    .table-portal td { display: block; }
    .table-portal th,
    .table-portal td { width: auto; max-width: none; }
    .table-portal tbody tr {
        border: 1px solid #e9ecef;
        border-radius: 10px;
        margin-bottom: 0.75rem;
        padding: 6px;
        background: #fff;
    }
    .table-portal tbody tr:last-child { margin-bottom: 0; }
    .table-portal tbody tr td {
        border-bottom: none;
        padding: 6px 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        text-align: left;
    }
    .table-portal tbody tr td:last-child { border-bottom: none; }
    .table-portal td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--portal-muted);
    }
    .table-portal .td-valor::before { content: 'Valor'; }
    .table-portal td[data-label=""]::before { display: none; }
    .table-portal td[data-label=""] { align-items: flex-end; }
    .table-portal td .btn-ver-boleto { align-self: flex-start; }
    /* Descrição e textos longos usam largura total, quebram por palavra */
    .table-portal tbody tr td { word-break: normal; overflow-wrap: break-word; min-width: 0; }
}

/* Badges */
.badge-pendente { background: #fd7e14; font-weight: 500; }
.badge-vencido { background: #dc3545; font-weight: 500; }
.badge-protestado { background: #b45309; font-weight: 500; }
.badge-pago { background: #198754; font-weight: 500; }
.badge-cancelado { background: #6c757d; font-weight: 500; }

/* Linhas de destaque */
.table-portal tr.row-vencido {
    background: rgba(220, 53, 69, 0.08) !important;
    border-left: 3px solid #dc3545;
}
.table-portal tr.row-vencido:hover { background: rgba(220, 53, 69, 0.12) !important; }
.table-portal tr.row-vencido td { font-weight: 500; }
.table-portal tr.row-protestado {
    background: rgba(180, 83, 9, 0.08) !important;
    border-left: 3px solid #b45309;
}
.table-portal tr.row-protestado:hover { background: rgba(180, 83, 9, 0.12) !important; }
.table-portal tr.row-protestado td { font-weight: 500; }
.table-portal .td-vencido-alert { color: #dc3545; font-weight: 600; }
.table-portal .td-protestado-alert { color: #b45309; font-weight: 600; }

.btn-ver-boleto {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    white-space: nowrap;
}
@media (min-width: 576px) {
    .btn-ver-boleto { font-size: 0.8125rem; padding: 0.35rem 0.75rem; }
}

/* Recebidos: toggle */
.portal-recebidos-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 6px;
    border: none;
    border-bottom: 1px solid #e9ecef;
    background: #fafbfc;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--portal-text);
    text-align: left;
    cursor: pointer;
}
.portal-card:has(.collapse:not(.show)) .portal-recebidos-toggle {
    border-bottom: none;
    border-radius: 0 0 12px 12px;
}
@media (min-width: 576px) {
    .portal-recebidos-toggle { padding: 6px; font-size: 1rem; }
}
.portal-recebidos-toggle:hover { background: #f1f3f5; }
.portal-recebidos-toggle .chevron { transition: transform 0.2s ease; flex-shrink: 0; }
.portal-recebidos-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* Ver mais */
.portal-ver-mais {
    padding: 6px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}
.portal-ver-mais .btn-ver-mais { font-size: 0.875rem; font-weight: 500; color: var(--portal-primary); }
.portal-ver-mais .btn-ver-mais:hover { color: #0a58ca; }

/* Estado vazio */
.portal-empty {
    padding: 6px;
    text-align: center;
    color: var(--portal-muted);
}
.portal-empty i { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; opacity: 0.6; }

/* Rodapé do site (dados da empresa + nota de segurança) */
.portal-site-footer {
    margin-top: 2rem;
    padding: 1.25rem 1rem;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}
.portal-footer-inner {
    max-width: 960px;
    margin: 0 auto;
    text-align: center;
}
.portal-footer-company {
    font-size: 1rem;
    font-weight: 600;
    color: var(--portal-text);
    margin: 0 0 0.5rem 0;
}
.portal-footer-note {
    font-size: 0.75rem;
    color: var(--portal-muted);
    margin: 0;
}
@media (min-width: 576px) {
    .portal-site-footer { padding: 1.5rem 1.25rem; }
    .portal-footer-company { font-size: 1.0625rem; }
    .portal-footer-note { font-size: 0.8125rem; }
}
