/* ══════════════════════════════════════════════════════════════
   Gestão Condominial — estilos próprios (sobre o Bootstrap 5)
   Cores centralizadas aqui para permitir identidade configurável.
   ══════════════════════════════════════════════════════════════ */

:root {
    --app-primary: #1f3b6f;
    --app-primary-hover: #17305c;
    --app-sidebar-bg: #ffffff;
    --app-bg: #f3f5f9;
    --app-sidebar-width: 240px;
    --bs-primary: var(--app-primary);
    --bs-primary-rgb: 31, 59, 111;
    --bs-link-color: var(--app-primary);
    --bs-link-color-rgb: 31, 59, 111;
}

body { background: var(--app-bg); }

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-hover);
    --bs-btn-hover-border-color: var(--app-primary-hover);
    --bs-btn-active-bg: var(--app-primary-hover);
}
.btn-outline-primary {
    --bs-btn-color: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary);
    --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-active-bg: var(--app-primary);
}

/* ── Navbar ─────────────────────────────────────────────────── */
.app-navbar { background: var(--app-primary); min-height: 56px; }
.app-logo { display: block; height: 34px; width: auto; }
@media (max-width: 575.98px) { .app-logo { height: 26px; } }
.auth-logo-img { display: block; width: 100%; max-width: 280px; height: auto; margin: 0 auto; }
.avatar-circle {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,.2); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 600;
}

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: calc(100vh - 56px); }
.app-content { flex: 1; min-width: 0; padding: 1.5rem; }

@media (min-width: 992px) {
    .app-sidebar {
        width: var(--app-sidebar-width);
        flex-shrink: 0;
        background: var(--app-sidebar-bg);
        border-right: 1px solid #e3e8f0;
        position: sticky; top: 56px;
        height: calc(100vh - 56px);
        overflow-y: auto;
    }
}
@media (max-width: 575.98px) {
    .app-content { padding: 1rem; }
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar-nav { padding: .75rem 0; }
.sidebar-nav .nav-link {
    color: #44506a; padding: .55rem 1.25rem;
    display: flex; align-items: center; gap: .75rem;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover { background: #f1f4fa; color: var(--app-primary); }
.sidebar-nav .nav-link.active {
    background: #e8eef9; color: var(--app-primary);
    border-left-color: var(--app-primary); font-weight: 600;
}
.sidebar-nav .nav-link .bi { font-size: 1.1rem; }
.sidebar-header {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
    color: #8a94a6; padding: 1rem 1.25rem .25rem;
}

/* ── Componentes ────────────────────────────────────────────── */
.card { border-color: #e3e8f0; }
.kpi-card { transition: transform .1s, box-shadow .1s; }
a.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 .25rem .75rem rgba(0,0,0,.06); }
.portaria-btn { font-weight: 600; }
.form-narrow { max-width: 480px; }
.form-narrow-lg { max-width: 900px; }
.morador-foto-xs { width: 36px; height: 36px; object-fit: cover; }
.morador-foto-sm { width: 56px; height: 56px; object-fit: cover; }
.morador-foto-lg { width: 120px; height: 120px; object-fit: cover; }
.avatar-placeholder {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: #e8eef9; color: var(--app-primary);
}
.avatar-placeholder.lg { width: 120px; height: 120px; font-size: 3rem; border-radius: .5rem; }
.anexo-thumb { width: 96px; height: 96px; object-fit: cover; }
.anexo-file {
    width: 96px; height: 96px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: .25rem; padding: .25rem; color: var(--app-primary);
}
.anexo-file .small { max-width: 88px; }
.anexo-remover { position: absolute; top: 2px; right: 2px; }
.timeline { list-style: none; padding-left: 0; border-left: 2px solid #e3e8f0; margin-left: .5rem; }
.timeline > li { position: relative; padding: 0 0 1rem 1.25rem; }
.timeline > li::before {
    content: ''; position: absolute; left: -7px; top: .35rem; width: 12px; height: 12px;
    border-radius: 50%; background: #fff; border: 2px solid var(--app-primary);
}
.timeline > li.interno::before { border-color: #fd7e14; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: #e3e8f0; border: 1px solid #e3e8f0; }
.cal-grid > div { background: #fff; min-height: 96px; padding: .25rem; font-size: .8rem; }
.cal-grid > .cal-head { min-height: auto; text-align: center; font-weight: 600; background: #f3f5f9; }
.cal-grid > .cal-out { background: #f8f9fb; color: #adb5bd; }
.cal-grid > .cal-hoje { outline: 2px solid var(--app-primary); outline-offset: -2px; }
.cal-grid > .cal-bloqueado { background: repeating-linear-gradient(45deg, #fff8e6, #fff8e6 6px, #fff1cc 6px, #fff1cc 12px); }
.cal-evt-bloqueio { background: #fd7e14; color: #fff; }
.cal-evt { display: block; border-radius: .25rem; padding: 1px 4px; margin-top: 2px; text-decoration: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (max-width: 575.98px) { .cal-grid > div { min-height: 64px; font-size: .7rem; } }
.baixa-form { min-width: 220px; }
/* Ações das listas financeiras: botões lado a lado, alinhados à direita */
.acoes-linha { display: flex; flex-wrap: nowrap; justify-content: flex-end; align-items: center; gap: .35rem; }
.acoes-linha > form { margin: 0; }
.camera-video { display: block; width: 100%; max-height: 340px; margin-top: .5rem; border-radius: .5rem; background: #000; object-fit: cover; }
.camera-previa { display: block; max-width: 100%; max-height: 220px; border-radius: .5rem; border: 1px solid #dee2e6; }
.holerite-ref { width: 80px; } .holerite-valor { width: 110px; }
.comprovante-foto { max-height: 220px; object-fit: cover; }
.diag-log { max-height: 360px; overflow: auto; white-space: pre-wrap; font-size: .75rem; background: #f8f9fb; }
.preview-table { max-height: 480px; overflow-y: auto; }
progress { height: .6rem; }
progress.voto-sim { accent-color: #198754; }
progress.voto-nao { accent-color: #dc3545; }
progress.voto-abstencao { accent-color: #6c757d; }
.presenca-lista { max-height: 280px; overflow-y: auto; }
.ata-texto { white-space: normal; line-height: 1.7; }
.leitor-qr { position: relative; background: #000; border-radius: .5rem; overflow: hidden; aspect-ratio: 1 / 1; }
.leitor-qr video { width: 100%; height: 100%; object-fit: cover; display: block; }
.leitor-mira {
    position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: .75rem;
    box-shadow: 0 0 0 999px rgba(0,0,0,.35);
}
.chart-box { position: relative; height: 280px; }
/* Assinatura na tela (retirada de encomenda) */
.assinatura-pad {
    display: block; width: 100%; height: 170px;
    background: #fff; border: 1px dashed #9aa6b8; border-radius: 8px;
    touch-action: none; cursor: crosshair;
}
.assinatura-pad.is-invalid { border-color: var(--bs-danger); }
.assinatura-img { display: block; max-width: 100%; height: 120px; object-fit: contain; }
.assinatura-legenda { max-width: 320px; }

/* Busca de pessoa no cadastro de usuário */
.busca-resultados { max-height: 320px; overflow-y: auto; }

/* Assembleia: cronômetro, botões de voto e grade de presença */
.cronometro-box { text-align: center; border: 1px solid #dee2e6; border-radius: .5rem; padding: .75rem; margin-bottom: .75rem; background: #f8f9fb; }
.cronometro { font-size: 2.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--app-primary); }
.cronometro-alerta { color: #dc3545; animation: pisca 1s steps(2) infinite; }
.cronometro-fim { color: #dc3545; font-size: 1.6rem; }
@keyframes pisca { 50% { opacity: .45; } }
.voto-opcoes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.voto-opcoes .voto-btn { min-height: 64px; font-size: 1.15rem; font-weight: 600; border-width: 2px; }
.voto-opcoes .voto-btn .bi { font-size: 1.3rem; }
.voto-escolhido { box-shadow: 0 0 0 .25rem rgba(0, 0, 0, .12); }
.mesa-votos { max-height: 420px; overflow-y: auto; border: 1px solid #eef1f6; border-radius: .375rem; }
.mesa-voto-linha { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .35rem .5rem; margin: 0; border-bottom: 1px solid #eef1f6; }
.mesa-voto-linha:last-child { border-bottom: 0; }
.mesa-voto-unidade { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.presenca-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .4rem; max-height: 360px; overflow-y: auto; padding: 2px; }
.presenca-btn { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: .4rem .55rem; line-height: 1.15; min-width: 0; }
.presenca-unidade { font-weight: 700; font-size: .95rem; }
.presenca-dono { font-size: .7rem; opacity: .85; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 575.98px) { .voto-opcoes .voto-btn { min-height: 56px; font-size: 1rem; } .cronometro { font-size: 2.2rem; } }

@media print {
    .app-navbar, .app-sidebar, .no-print, .breadcrumb, .btn { display: none !important; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .card { border: 0; }
}
.preview-grid { display: flex; flex-wrap: wrap; gap: .35rem; max-height: 320px; overflow-y: auto; }
.table > :not(caption) > * > * { vertical-align: middle; }

/* ── Telas de autenticação ──────────────────────────────────── */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 16px;
    background: linear-gradient(135deg, #e9eef7 0%, #f6f8fb 100%);
}
.auth-card { width: 100%; max-width: 420px; border: 0; }
.auth-card.auth-card-wide { max-width: 760px; }
.auth-logo {
    width: 56px; height: 56px; border-radius: 14px; margin: 0 auto;
    background: var(--app-primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
}
.otp-digit { width: 48px; height: 56px; padding: 0; }

/* Página offline do PWA: independente do Bootstrap (CDN indisponível sem rede) */
.offline-card {
    width: 100%; max-width: 420px; background: #fff; border-radius: 12px; padding: 2rem;
    text-align: center; box-shadow: 0 .5rem 1.5rem rgba(0,0,0,.08); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.offline-card h1 { font-size: 1.25rem; margin: 1rem 0 .5rem; color: #253046; }
.offline-card p { color: #6c757d; font-size: .9rem; line-height: 1.5; }
.offline-btn {
    display: block; margin-top: 1.25rem; padding: .65rem; border-radius: .5rem;
    background: var(--app-primary); color: #fff; text-decoration: none; font-weight: 600;
}
@media (max-width: 380px) { .otp-digit { width: 40px; height: 50px; } }

/* Logo do condomínio (Administração → Condomínios → Personalização dos documentos) */
.logo-previa { height: 110px; }
.logo-previa-img { max-height: 94px; object-fit: contain; }
.comunicado-logo { max-height: 56px; max-width: 200px; object-fit: contain; }

/* Demonstrativo da cobrança: logo do condomínio */
.demonstrativo-logo { max-height: 56px; max-width: 160px; object-fit: contain; }

/* Só na impressão (ex.: assinaturas do espelho de ponto) */
.print-only { display: none; }
@media print { .print-only { display: flex !important; } }
