/* ============================================================
   Church Attendance System — Global Styles
   ============================================================ */

:root {
    --primary:   #2C5F8A;
    --secondary: #1A3A5C;
    --accent:    #F4A261;
    --sidebar-w: 260px;
    --radius:    10px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f0f4f8;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #2d3748;
}

/* ---- Navbar ---- */
.app-navbar {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
    box-shadow: 0 2px 12px rgba(0,0,0,.18);
    z-index: 1030;
}

.app-navbar .navbar-brand { font-size: 1.1rem; letter-spacing: .3px; }
.app-navbar .nav-link { font-size: .9rem; padding: .5rem .8rem; opacity: .85; transition: opacity .2s; }
.app-navbar .nav-link:hover, .app-navbar .nav-link.active { opacity: 1; }
.app-navbar .nav-link.active { font-weight: 600; border-bottom: 2px solid var(--accent); }
.app-navbar .dropdown-menu { border: none; box-shadow: 0 6px 24px rgba(0,0,0,.12); border-radius: var(--radius); }

.church-logo-sm { width: 36px; height: 36px; object-fit: cover; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); }

/* ---- Page Wrapper ---- */
.page-wrapper { flex: 1; padding: 1.5rem; }

/* ---- Page Header ---- */
.page-header {
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .6rem;
}
.page-header h1 { font-size: 1.2rem; font-weight: 700; color: var(--secondary); margin: 0; }
.page-header .breadcrumb { margin: 0; font-size: .82rem; }
.page-header-actions {
    display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
}

/* ---- Stat Cards ---- */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
    box-shadow: 0 1px 8px rgba(0,0,0,.06);
    transition: transform .2s, box-shadow .2s;
    border-left: 4px solid var(--primary);
    position: relative;
    overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.stat-card .stat-icon {
    position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
    font-size: 3rem; opacity: .08; color: var(--primary);
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--secondary); line-height: 1.1; }
.stat-card .stat-label { font-size: .82rem; color: #718096; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-top: .25rem; }
.stat-card .stat-change { font-size: .8rem; margin-top: .4rem; }

.stat-card.accent  { border-left-color: var(--accent); }
.stat-card.success { border-left-color: #38a169; }
.stat-card.warning { border-left-color: #d69e2e; }
.stat-card.danger  { border-left-color: #e53e3e; }
.stat-card.info    { border-left-color: #3182ce; }

/* ---- Evangelism summary (evangelism/reports.php, evangelism/my-reports.php) ---- */
.ev-stats .stat-card { height: 100%; padding: 1.1rem 1.25rem; }
.ev-stats .stat-card .stat-value { font-size: 1.75rem; }
.ev-tribe-card { border-top: 3px solid var(--primary); transition: box-shadow .2s; }
.ev-tribe-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.ev-tribe-card.ev-tribe-due { border-top-color: #e53e3e; }

/* ---- Cards ---- */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 1px 8px rgba(0,0,0,.06);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #e8edf2;
    font-weight: 600;
    color: var(--secondary);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding: 1rem 1.25rem;
}
.card-header .card-title { margin: 0; font-size: 1rem; }

/* ---- Tables ---- */
.table-card { background: #fff; border-radius: var(--radius); box-shadow: 0 1px 8px rgba(0,0,0,.06); overflow: hidden; }
.table-card .table { margin: 0; }
.table-card .table thead th {
    background: #f7fafc; border-bottom: 2px solid #e8edf2;
    font-size: .82rem; text-transform: uppercase; letter-spacing: .5px;
    color: #718096; font-weight: 600; padding: .9rem 1rem;
}
.table-card .table tbody td { padding: .85rem 1rem; vertical-align: middle; border-bottom: 1px solid #f0f4f8; font-size: .9rem; }
.table-card .table tbody tr:last-child td { border-bottom: none; }
.table-card .table tbody tr:hover td { background: #f7fafc; }

/* ---- Badges ---- */
.badge-present { background: #c6f6d5; color: #276749; font-weight: 600; border-radius: 20px; }
.badge-absent  { background: #fed7d7; color: #9b2c2c; font-weight: 600; border-radius: 20px; }
.badge-visitor { background: #bee3f8; color: #2a69ac; font-weight: 600; border-radius: 20px; }
.badge-new     { background: #feebc8; color: #7b341e; font-weight: 600; border-radius: 20px; }

/* ---- Forms ---- */
.form-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 8px rgba(0,0,0,.06);
    padding: 1.75rem;
}
.form-label { font-weight: 500; font-size: .9rem; color: var(--secondary); }
.form-control, .form-select {
    border-radius: 7px; border-color: #cbd5e0; font-size: .9rem;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 95, 138, .15);
}
.input-group-text { background: #f7fafc; border-color: #cbd5e0; }

/* ---- Buttons ---- */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--secondary); border-color: var(--secondary); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.9); color: #fff; }

/* ---- QR Code ---- */
.qr-wrapper {
    background: #fff;
    border: 2px solid #e8edf2;
    border-radius: 16px;
    padding: 1.5rem;
    display: inline-block;
    box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.qr-wrapper canvas, .qr-wrapper img { display: block; }

/* ---- QR Scanner ---- */
#qr-reader { width: 100%; max-width: 500px; border-radius: 12px; overflow: hidden; }
#qr-reader video { border-radius: 12px; }

/* ---- Attendance Status Indicators ---- */
.attendance-dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; margin-right: 6px;
}
.attendance-dot.present { background: #38a169; }
.attendance-dot.absent  { background: #e53e3e; }

/* ---- Calendar Heatmap ---- */
.attendance-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.att-cell {
    width: 24px; height: 24px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: .65rem; font-weight: 600; cursor: default;
    transition: transform .15s;
}
.att-cell:hover { transform: scale(1.2); }
.att-cell.present  { background: #c6f6d5; color: #276749; }
.att-cell.absent   { background: #fed7d7; color: #9b2c2c; }
.att-cell.no-data  { background: #e8edf2; color: #a0aec0; }

/* ---- Member Card ---- */
.member-card {
    background: #fff; border-radius: var(--radius);
    padding: 1rem; box-shadow: 0 1px 8px rgba(0,0,0,.06);
    transition: transform .2s;
}
.member-card:hover { transform: translateY(-2px); }
.member-avatar {
    width: 48px; height: 48px; border-radius: 50%; object-fit: cover;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 700;
}

/* ---- Church Branding Preview ---- */
.branding-preview {
    border: 1px solid #e8edf2; border-radius: 8px; overflow: hidden;
}
.branding-preview .preview-nav {
    height: 48px; display: flex; align-items: center; padding: 0 1rem;
    gap: 1rem; color: #fff; font-size: .85rem; font-weight: 600;
}

/* ---- Sidebar (for admin) ---- */
@media (min-width: 992px) {
    .layout-sidebar { display: flex; gap: 0; }
    .sidebar {
        width: var(--sidebar-w); min-height: calc(100vh - 56px);
        background: #fff; border-right: 1px solid #e8edf2;
        padding: 1rem 0; flex-shrink: 0;
        box-shadow: 2px 0 8px rgba(0,0,0,.04);
    }
    .sidebar-content { flex: 1; padding: 1.5rem; }
}

.sidebar-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem 1.25rem; color: #4a5568; font-size: .9rem;
    text-decoration: none; border-radius: 0; transition: all .15s;
    border-left: 3px solid transparent;
}
.sidebar-link:hover { background: #f0f4f8; color: var(--primary); }
.sidebar-link.active { background: rgba(44,95,138,.06); color: var(--primary); font-weight: 600; border-left-color: var(--primary); }
.sidebar-link .bi { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-heading {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .7px; color: #a0aec0; padding: 1rem 1.25rem .25rem;
}

/* ---- Chart Container ---- */
.chart-container { position: relative; min-height: 260px; }

/* ---- Notification Item ---- */
.notif-item { padding: .85rem 1rem; border-bottom: 1px solid #f0f4f8; transition: background .15s; }
.notif-item:hover { background: #f7fafc; }
.notif-item.unread { background: #ebf5ff; }
.notif-item:last-child { border-bottom: none; }

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 60%, var(--accent) 100%);
    padding: 1rem;
}
.login-card {
    background: #fff; border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    width: 100%; max-width: 440px;
    overflow: hidden;
}
.login-card .login-header {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    padding: 2rem; text-align: center; color: #fff;
}
.login-card .login-header img { width: 72px; height: 72px; border-radius: 50%; border: 3px solid rgba(255,255,255,.4); object-fit: cover; }
.login-card .login-body { padding: 2rem; }

/* ---- Footer ---- */
.app-footer {
    background: #fff;
    border-top: 1px solid #e8edf2;
    font-size: .82rem;
}

/* ---- Responsive ---- */
@media (max-width: 767px) {
    .page-wrapper { padding: .75rem .6rem; }
    .stat-card { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.5rem; }
    .stat-card .stat-icon { font-size: 2rem; }
    .page-header { padding: .75rem 1rem; }
    .page-header h1 { font-size: 1.05rem; }
    .page-header-actions .btn { font-size: .75rem; padding: .3rem .6rem; }
    .page-header-actions .badge { font-size: .7rem !important; }
    .table-card .table thead th { font-size: .75rem; padding: .6rem .75rem; }
    .table-card .table tbody td { font-size: .82rem; padding: .6rem .75rem; }
    /* Prevent horizontal overflow */
    .container-fluid { overflow-x: hidden; }
    .row { --bs-gutter-x: .75rem; }
}

/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .4s ease forwards; }

/* ---- Utility ---- */
.text-primary-custom { color: var(--primary) !important; }
.bg-primary-custom   { background: var(--primary) !important; }
.border-primary-custom { border-color: var(--primary) !important; }
.rounded-xl { border-radius: 16px !important; }

/* ---- Print ---- */
@media print {
    .app-navbar, .app-footer, .btn, .no-print { display: none !important; }
    body { background: #fff; }
    /* Keep each card whole — without this, Chrome slices a card in half
       right at the page boundary instead of pushing it to the next page,
       so its bottom rows/border silently disappear from the printed PDF. */
    .card { break-inside: avoid; page-break-inside: avoid; }
    /* Chrome/Edge draw their own "date + title" header and "URL + page
       number" footer inside the page margin reserved for them. Zeroing
       that margin leaves them no room to draw, which suppresses them —
       so the margin has to be recreated as inner padding instead, or
       content would print flush to the paper's unprintable edge. */
    @page { margin: 0; }
    .page-wrapper { padding: 14mm 12mm !important; }
}
