/* ══════════════════════════════════════════════════════════════════
   Igreja Pastoral – App CSS (Mobile First, Responsive)
   ══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
    --primary:      #1a56a4;
    --primary-dark: #133d7a;
    --primary-light:#dbeafe;
    --secondary:    #16a34a;
    --accent:       #f59e0b;
    --danger:       #dc2626;
    --danger-light: #fee2e2;
    --bg:           #f1f5f9;
    --card:         #ffffff;
    --border:       #e2e8f0;
    --text:         #0f172a;
    --muted:        #64748b;
    --radius:       14px;
    --radius-sm:    8px;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
    --shadow-md:    0 4px 16px rgba(0,0,0,.12);
    --nav-h:        64px;
    --safe-top:     env(safe-area-inset-top, 0px);
    --safe-bottom:  env(safe-area-inset-bottom, 0px);
    --sidebar-w:    260px;
    --font:         'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ── LOGIN ─────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f2f5e 0%, #1a56a4 60%, #1d6fa5 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #2563eb);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 12px;
    box-shadow: 0 4px 16px rgba(26,86,164,.3);
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
}

.login-logo p {
    font-size: 14px;
    color: var(--muted);
    margin-top: 4px;
}

.login-error {
    background: var(--danger-light);
    border: 1px solid #fca5a5;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    color: var(--danger);
    margin-bottom: 16px;
}

/* ── LAYOUT PRINCIPAL ──────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: #0f2f5e;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform .3s ease;
    overflow-y: auto;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #1a56a4, #2563eb);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}

.sidebar-title { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.sidebar-sub   { color: rgba(255,255,255,.5); font-size: 11px; }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.35);
    padding: 12px 20px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,.7);
    font-size: 14px;
    font-weight: 500;
    border-radius: 0;
    transition: all .15s;
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: #60a5fa;
    border-radius: 0 3px 3px 0;
}

.nav-icon { font-size: 18px; flex-shrink: 0; width: 22px; text-align: center; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
}

.user-info {
    display: flex; align-items: center; gap: 10px;
}

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #1a56a4, #60a5fa);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}

.user-name  { color: #fff; font-size: 13px; font-weight: 600; }
.user-role  { color: rgba(255,255,255,.5); font-size: 11px; }

.btn-logout {
    display: flex; align-items: center; gap: 6px;
    margin-top: 10px; padding: 8px 12px;
    background: rgba(255,255,255,.08);
    border: none; border-radius: var(--radius-sm);
    color: rgba(255,255,255,.7); font-size: 13px; width: 100%;
    transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ── TOPBAR MOBILE ─────────────────────────────────────────────── */
.topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(var(--nav-h) + env(safe-area-inset-top));
    background: #0f2f5e;
    z-index: 150;
    align-items: flex-end;
    padding: 0 16px env(safe-area-inset-bottom, 0) 16px;
    padding-top: env(safe-area-inset-top);
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.topbar-title { color: #fff; font-size: 17px; font-weight: 700; flex: 1; }

.btn-menu {
    background: none; border: none;
    color: #fff; font-size: 22px;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
}

.topbar-badge {
    background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 700;
    padding: 2px 8px; border-radius: 99px;
}

/* Overlay sidebar mobile */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 190;
}

/* ── CONTEÚDO PRINCIPAL ────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-inner {
    padding: 28px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── CARDS ─────────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── KPIs ──────────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.kpi {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 16px;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--primary);
    text-align: center;
}

.kpi.green  { border-top-color: var(--secondary); }
.kpi.amber  { border-top-color: var(--accent); }
.kpi.red    { border-top-color: var(--danger); }

.kpi-num { font-size: 32px; font-weight: 800; color: var(--primary); }
.kpi.green .kpi-num { color: var(--secondary); }
.kpi.amber .kpi-num { color: var(--accent); }
.kpi.red   .kpi-num { color: var(--danger); }
.kpi-lbl   { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

/* ── BOTÕES ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600;
    border: none; cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--secondary); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-whatsapp  { background: #25D366; color: #fff; }
.btn-warning   { background: var(--accent);    color: #fff; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-ghost     { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #e2e8f0; }
.btn-sm        { padding: 6px 12px; font-size: 13px; }
.btn-lg        { padding: 14px 24px; font-size: 16px; }
.btn-full      { width: 100%; justify-content: center; }
.btn-icon      { padding: 8px; border-radius: var(--radius-sm); }

/* ── FORMULÁRIOS ───────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
    font-size: 12px; font-weight: 600;
    color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
}

.form-control {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 15px; color: var(--text);
    background: #fff; outline: none;
    transition: border-color .15s;
    width: 100%;
    -webkit-appearance: none;
}

.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,164,.12); }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ── SEÇÃO TÍTULO ──────────────────────────────────────────────── */
.section-title {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px;
    color: var(--primary);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
    margin-bottom: 14px;
}

/* ── TABELA ────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
.data-table th {
    background: var(--primary); color: #fff;
    padding: 11px 14px; text-align: left;
    font-weight: 600; font-size: 13px;
    white-space: nowrap;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover td { background: #f8fafc; }
.data-table .actions { white-space: nowrap; display: flex; gap: 6px; }

/* ── BADGES ────────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 99px;
    font-size: 12px; font-weight: 600;
}
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-amber  { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ── PROGRESS BAR ──────────────────────────────────────────────── */
.progress { background: #e2e8f0; border-radius: 99px; height: 10px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--secondary); transition: width .4s; }
.progress-bar.low { background: var(--danger); }

/* ── MODAL ─────────────────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.modal-overlay.open { display: flex; }

.modal {
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 24px 20px 32px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    animation: slideUp .25s ease;
}

@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.modal-handle {
    width: 40px; height: 4px;
    background: #e2e8f0; border-radius: 99px;
    margin: 0 auto 20px;
}

.modal-title {
    font-size: 18px; font-weight: 700;
    margin-bottom: 20px;
}

.modal-close {
    float: right; background: none; border: none;
    font-size: 22px; color: var(--muted); line-height: 1;
    padding: 0; margin-top: -2px;
}

/* ── FILTROS ───────────────────────────────────────────────────── */
.filters {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin-bottom: 16px; align-items: flex-end;
}

.filters .form-control { padding: 9px 12px; font-size: 14px; }

/* ── RADIO / CHECK CARDS ───────────────────────────────────────── */
.radio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 8px; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.radio-card, .check-card {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13px; font-weight: 500;
    transition: all .15s;
}

.radio-card:hover, .check-card:hover { border-color: var(--primary); background: #f0f4ff; }
.radio-card input, .check-card input { accent-color: var(--primary); flex-shrink: 0; margin-top: 2px; }
.radio-card:has(input:checked) { border-color: var(--primary); background: #dbeafe; color: var(--primary); font-weight: 700; }
.check-card:has(input:checked) { border-color: var(--secondary); background: #dcfce7; color: #166534; font-weight: 700; }

/* ── ABAS ──────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: -1px; }
.tab-btn {
    padding: 9px 18px; border-radius: 10px 10px 0 0;
    font-size: 13px; font-weight: 600;
    background: #e9eef5; color: var(--muted);
    border: 1px solid transparent; cursor: pointer;
    transition: all .15s;
}
.tab-btn.active { background: #fff; color: var(--primary); border-color: var(--border); border-bottom-color: #fff; }
.tab-content { background: #fff; border: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius); padding: 20px; }

/* ── ALERTAS ───────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.alert-danger  { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-info    { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; }

/* ── PAGINAÇÃO ─────────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.page-btn { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: #fff; font-size: 13px; color: var(--text); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── EMPTY STATE ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .sidebar         { transform: translateX(-100%); }
    .sidebar.open    { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .topbar          { display: flex; }
    .main-content    { margin-left: 0; padding-top: calc(var(--nav-h) + env(safe-area-inset-top)); }
    .page-inner      { padding: 16px; }
    .form-grid       { grid-template-columns: 1fr; }
    .kpi-grid        { grid-template-columns: repeat(2, 1fr); }
    .modal           { border-radius: 20px 20px 0 0; }
    .check-grid      { grid-template-columns: 1fr; }
    .filters         { flex-direction: column; }
    .filters .form-control { width: 100%; }
    .page-header     { flex-direction: column; align-items: flex-start; }
    .table-wrap      { margin: 0; border-radius: var(--radius-sm); }
    .data-table th, .data-table td { padding: 9px 10px; font-size: 13px; }
}

@media (min-width: 769px) {
    .modal-overlay   { align-items: center; padding: 20px; }
    .modal           { border-radius: 20px; max-width: 680px; }
    .modal-handle    { display: none; }
}

@media (min-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── PRINT ─────────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .btn, .filters, .modal-overlay { display: none !important; }
    .main-content { margin: 0; padding: 0; }
}
