/* =============================================
   Acesso Restrito Condomínio — Custom Styles (mobile-first)
   ============================================= */

:root {
    --primary:       #2563EB;
    --primary-dark:  #1D4ED8;
    --primary-light: #EFF6FF;
    --secondary:     #10B981;
    --danger:        #EF4444;
    --bg:            #F0F4FF;
    --surface:       #FFFFFF;
    --text:          #1E293B;
    --text-muted:    #64748B;
    --border:        #E2E8F0;
    --radius:        16px;
    --radius-sm:     10px;
    --shadow:        0 4px 24px rgba(37, 99, 235, 0.10);
    --header-h:      64px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Auth screens ─────────────────────────────── */
.auth-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.auth-hero {
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 56px 24px 48px;
    text-align: center;
    position: relative;
}

.auth-hero--sm {
    padding: 36px 24px 36px;
}

.btn-back {
    position: absolute;
    top: 20px;
    left: 20px;
    color: rgba(255,255,255,0.85);
    font-size: 1.25rem;
    text-decoration: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    transition: background 0.2s;
}
.btn-back:hover { background: rgba(255,255,255,0.25); color: #fff; }

.auth-logo img {
    width: 62%;
    height: 62%;
    object-fit: contain;
}
.auth-logo {
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.18);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 38px;
    backdrop-filter: blur(4px);
}
.auth-logo--sm { width: 60px; height: 60px; font-size: 28px; border-radius: 18px; }

.auth-title  { font-size: 1.65rem; font-weight: 700; margin: 0 0 4px; }
.auth-subtitle { font-size: 0.875rem; opacity: 0.82; margin: 0; }

.auth-form-wrap {
    flex: 1;
    padding: 0 16px 40px;
    margin-top: -24px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px 22px;
    box-shadow: var(--shadow);
}

/* ── App Header (authenticated) ──────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--primary);
    color: #fff;
    padding-top: env(safe-area-inset-top);
    box-shadow: 0 2px 10px rgba(37,99,235,0.25);
}

.header-inner {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: var(--header-h);
    gap: 12px;
}

.header-brand {
    display: none;
    align-items: center;
    font-weight: 700;
    font-size: 1rem;
    opacity: 0.92;
    flex-shrink: 0;
    padding-right: 20px;
    border-right: 1px solid rgba(255,255,255,0.2);
    margin-right: 4px;
}
.header-brand-logo {
    width: 26px;
    height: 26px;
    object-fit: contain;
    border-radius: 6px;
    margin-right: 8px;
}
.header-brand-name { letter-spacing: -0.01em; }

.header-info { flex: 1; min-width: 0; }
.header-user {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.header-location {
    font-size: 0.75rem;
    opacity: 0.78;
    margin-top: 1px;
}

.btn-logout {
    color: rgba(255,255,255,0.85);
    font-size: 1.3rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
    text-decoration: none;
    gap: 6px;
}
.btn-logout:hover { background: rgba(255,255,255,0.15); color: #fff; }
.btn-logout-label {
    display: none;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* ── App content area ─────────────────────────── */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--header-h));
}

.app-content {
    flex: 1;
    padding: 20px 16px;
    padding-bottom: max(96px, calc(env(safe-area-inset-bottom) + 80px));
}

/* ── Form controls ────────────────────────────── */
.form-heading {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
}

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 0.95rem;
    height: 56px;
    padding: 14px 14px 0;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    background: var(--primary-light);
}
input[type="date"].form-control {
    padding-top: 14px;
}

.form-floating { position: relative; }
.form-floating > label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ── Buttons ──────────────────────────────────── */
.btn-app {
    height: 52px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
}
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:active {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ── Alerts ───────────────────────────────────── */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
}
.alert-danger  { background: #FEE2E2; color: #991B1B; }
.alert-success { background: #DCFCE7; color: #166534; }

/* ── Section label ────────────────────────────── */
.section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.badge-count {
    background: var(--primary);
    color: #fff;
    border-radius: 20px;
    padding: 1px 7px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 4px;
}

/* ── Visitor cards ────────────────────────────── */
.visitor-list { display: flex; flex-direction: column; gap: 10px; }

.visitor-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border-left: 4px solid var(--secondary);
    transition: transform 0.15s;
}
.visitor-card:active { transform: scale(0.98); }

.visitor-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 6px;
}

.visitor-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.visitor-dates {
    display: flex;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    gap: 2px;
}

.badge-active {
    background: #DCFCE7;
    color: #15803D;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Empty state ──────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 52px; opacity: 0.3; display: block; margin-bottom: 12px; }
.empty-state p { margin: 4px 0; font-size: 0.9rem; }

/* ── FAB ──────────────────────────────────────── */
.fab {
    position: fixed;
    bottom: max(24px, env(safe-area-inset-bottom));
    right: 20px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    box-shadow: 0 4px 18px rgba(37,99,235,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    cursor: pointer;
    z-index: 150;
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.fab:hover  { transform: scale(1.06); box-shadow: 0 6px 24px rgba(37,99,235,0.55); }
.fab:active { transform: scale(0.96); }

/* ── Modal ────────────────────────────────────── */
.modal-content {
    border-radius: var(--radius);
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.modal-header { padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-body   { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); }
.modal-title  { font-size: 1rem; font-weight: 700; }

/* ── Acesso group (radio selector) ─────────────── */
.acesso-group {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 6px 6px;
    background: var(--bg);
    margin: 0;
}

.acesso-legend {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    padding: 0 6px;
    margin-left: 6px;
    width: auto;
    float: none;
}

.acesso-option {
    display: flex;
    align-items: center;
    padding: 11px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
    width: 100%;
    margin: 0;
}
.acesso-option:hover { background: rgba(37,99,235,0.06); color: var(--text); }
.btn-check:checked + .acesso-option {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* badge tipo_acesso nos cards */
.badge-acesso {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    flex-shrink: 0;
}
.badge-acesso--sem {
    background: #DCFCE7;
    color: #15803D;
}
.badge-acesso--com {
    background: #FEF9C3;
    color: #92400E;
}

/* ── Install banner ───────────────────────────── */
.install-banner {
    margin-top: 16px;
    background: var(--primary-light);
    border: 1px solid #BFDBFE;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
}

/* ── Tablet / small desktop (≥ 640px) ────────── */
@media (min-width: 640px) {
    .auth-form-wrap {
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
        padding-top: 20px;
    }
    .auth-hero { padding: 72px 24px 56px; }
    .app-content {
        max-width: 760px;
        margin-left: auto;
        margin-right: auto;
        padding: 24px 24px;
        padding-bottom: max(96px, calc(env(safe-area-inset-bottom) + 80px));
    }
    .modal-dialog { max-width: 480px; }
}

/* ── Desktop (≥ 768px) ────────────────────────── */
@media (min-width: 768px) {
    /* Auth: layout lado a lado */
    .auth-screen {
        flex-direction: row;
        align-items: stretch;
        min-height: 100vh;
    }

    .auth-hero {
        flex: 0 0 44%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 64px 48px;
        border-radius: 0;
        min-height: 100vh;
    }

    .auth-hero--sm { padding: 64px 48px; }

    .auth-logo { width: 96px; height: 96px; font-size: 46px; border-radius: 28px; }
    .auth-logo--sm { width: 80px; height: 80px; font-size: 38px; border-radius: 22px; }
    .auth-title { font-size: 2rem; }

    .auth-form-wrap {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 48px 40px;
        margin-top: 0;
        max-width: none;
        background: var(--bg);
    }

    .auth-card {
        width: 100%;
        max-width: 420px;
        padding: 40px 36px;
        box-shadow: 0 8px 40px rgba(37,99,235,0.12);
    }

    .btn-back { top: 28px; left: 28px; }

    /* Header: brand + conteúdo centrado */
    .header-inner {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 32px;
    }

    .header-brand { display: flex; }

    .btn-logout {
        width: auto;
        border-radius: var(--radius-sm);
        padding: 0 14px;
        font-size: 1.05rem;
    }
    .btn-logout-label { display: inline; }

    /* Conteúdo principal: mais largo */
    .app-content {
        max-width: 1100px;
        padding: 32px 40px;
        padding-bottom: 80px;
    }

    /* Visitor list: grid 2 colunas */
    .visitor-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    /* Cards: hover no desktop (sem active scale) */
    .visitor-card:active { transform: none; }
    .visitor-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0,0,0,0.10);
        transition: transform 0.18s, box-shadow 0.18s;
    }

    /* FAB: melhor posicionamento */
    .fab {
        bottom: 40px;
        right: 40px;
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    /* Modal mais espaçosa */
    .modal-dialog { max-width: 520px; }
    .modal-body   { padding: 28px; }
    .modal-header { padding: 24px 28px; }
    .modal-footer { padding: 18px 28px; }
}

/* ── Wide desktop (≥ 1200px) ─────────────────── */
@media (min-width: 1200px) {
    .auth-hero { flex: 0 0 48%; }

    .visitor-list {
        grid-template-columns: repeat(3, 1fr);
    }

    .app-content { max-width: 1280px; padding: 36px 48px; padding-bottom: 80px; }
}
