/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
    --primary:        #1e3a8a;
    --primary-light:  #2563eb;
    --primary-hover:  #172554;
    --accent:         #3b82f6;
    --text-main:      #0f172a;
    --text-secondary: #1e293b;
    --text-muted:     #64748b;
    --bg-main:        #f1f5f9;
    --bg-card:        #ffffff;
    --border:         #e2e8f0;
    --border-strong:  #cbd5e1;
    --danger:         #dc2626;
    --success:        #059669;
    --sidebar-width:  268px;
    --radius:         12px;
    --radius-sm:      7px;
    --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
    --shadow:         0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg:      0 10px 25px -5px rgba(0,0,0,0.12), 0 4px 10px -2px rgba(0,0,0,0.06);
    --transition:     0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Alerts / Flash Messages ───────────────────────────────────────────────── */
.alert {
    padding: 0.875rem 1.125rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #dc2626; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #22c55e; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #3b82f6; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #f59e0b; }

/* ── Authentication Page ───────────────────────────────────────────────────── */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e40af 100%);
}
.login-card {
    background: #fff;
    padding: 2.75rem 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    border: 1px solid rgba(255,255,255,0.1);
}
.login-card h2 {
    margin-bottom: 1.75rem;
    color: var(--text-main);
    font-weight: 700;
    font-size: 1.4rem;
    text-align: center;
    letter-spacing: -0.02em;
}

/* Login Header */
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo {
    max-width: 84px;
    border-radius: 50%;
    display: block;
    margin: 0 auto 1.125rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 3px solid #e2e8f0;
}
.login-title { font-size: 1.15rem; font-weight: 700; color: var(--text-main); margin-bottom: 0.25rem; letter-spacing: -0.01em; }
.login-subtitle { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    margin-bottom: 0.45rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.82rem;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}
.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.925rem;
    color: var(--text-main);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
select.form-control { cursor: pointer; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem 1.4rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    text-decoration: none;
    width: 100%;
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}
.btn:hover {
    background: var(--primary-light);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn-inline { width: auto; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35); }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; box-shadow: 0 4px 12px rgba(100, 116, 139, 0.35); }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.05);
    z-index: 1000;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
    flex-shrink: 0;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

/* Sidebar Logo Area */
.logo {
    text-align: center;
    padding: 2rem 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    margin-bottom: 0.5rem;
    position: relative;
}
.church-logo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1rem;
    display: block;
    border: 3px solid rgba(59, 130, 246, 0.6);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}
.church-name {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.35;
    color: #f1f5f9;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    word-break: break-word;
}
.church-assembly {
    font-size: 0.73rem;
    color: #64748b;
    margin-top: 0.35rem;
    line-height: 1.4;
}

/* Navigation */
.menu {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    flex: 1;
    gap: 2px;
}
.menu-section-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #475569;
    padding: 1.1rem 0.75rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.menu-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.07);
    border-radius: 1px;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.68rem 0.875rem;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    position: relative;
}
.menu-item:hover {
    background: rgba(255,255,255,0.07);
    color: #e2e8f0;
}
.menu-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    font-weight: 600;
    border-left-color: var(--accent);
}
.menu-item.active .menu-icon {
    background: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}
.menu-item.logout {
    color: #f87171;
    margin-top: auto;
}
.menu-item.logout:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border-left-color: #ef4444;
}
.menu-item.logout .menu-icon { color: #f87171; }
.menu-item.logout:hover .menu-icon { background: rgba(239,68,68,0.18); color: #fca5a5; }
.menu-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.menu-item:hover .menu-icon {
    background: rgba(255,255,255,0.09);
}
.menu-item-draft { opacity: 0.55; }
.draft-badge {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(217, 119, 6, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.25);
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: auto;
    letter-spacing: 0.05em;
}

/* ── Mobile Header ─────────────────────────────────────────────────────────── */
.mobile-header {
    display: none;
    background: #0f172a;
    color: #fff;
    padding: 0 1.25rem;
    height: 60px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.menu-toggle {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), background var(--transition);
}
.menu-toggle:hover { background: rgba(255,255,255,0.08); color: #f1f5f9; }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 950;
    backdrop-filter: blur(2px);
}

/* ── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem;
    overflow-y: auto;
}

/* Top Header Bar */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: #fff;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.header-breadcrumb { color: var(--text-muted); font-size: 0.85rem; }
.user-profile { display: flex; align-items: center; gap: 0.875rem; }
.user-info { display: flex; flex-direction: column; align-items: flex-end; }
.user-name { font-weight: 600; color: var(--text-main); font-size: 0.875rem; line-height: 1.2; }
.user-role { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 1px; }
.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    box-shadow: 0 2px 6px rgba(30, 58, 138, 0.3);
    flex-shrink: 0;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.03em;
    line-height: 1.2;
}
.page-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
    letter-spacing: -0.01em;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.6rem;
    color: var(--text-muted);
}
.card-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.03em;
    line-height: 1;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.stats-grid .card {
    border-top: 3px solid var(--accent);
    padding: 1.25rem 1.5rem;
}
.stats-grid .card:nth-child(2) { border-top-color: #8b5cf6; }
.stats-grid .card:nth-child(3) { border-top-color: #10b981; }
.stats-grid .card:nth-child(4) { border-top-color: #f59e0b; }
.activity-card { margin-top: 0; }
.activity-empty { color: var(--text-muted); font-style: italic; font-size: 0.875rem; padding: 2rem 0; text-align: center; display: block; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 0.875rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 0.875rem; }
th {
    background: #f8fafc;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    border-bottom: 2px solid var(--border-strong);
    white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: #f8fafc; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid transparent;
    letter-spacing: 0.02em;
}
.badge-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.badge-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* Role Badges */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── Action Links ──────────────────────────────────────────────────────────── */
.action-link { text-decoration: none; font-size: 0.825rem; font-weight: 600; transition: opacity var(--transition); }
.action-link:hover { opacity: 0.75; text-decoration: none; }
.action-link.edit { color: var(--primary-light); margin-right: 1rem; }
.action-link.delete { color: var(--danger); }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
}
.pagination-info { font-size: 0.825rem; color: var(--text-muted); }
.pagination-controls { display: flex; gap: 0.35rem; }
.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.625rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.825rem;
    font-weight: 500;
    transition: all var(--transition);
}
.pagination-link:hover { background: #f1f5f9; border-color: var(--border-strong); }
.pagination-link.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 6px rgba(30,58,138,0.3); }
.pagination-link.disabled { background: #f8fafc; color: #cbd5e1; cursor: not-allowed; border-color: var(--border); pointer-events: none; }

/* ── Search ────────────────────────────────────────────────────────────────── */
.search-container { display: flex; align-items: center; position: relative; max-width: 300px; width: 100%; }
.search-input {
    width: 100%;
    padding: 0.55rem 1rem 0.55rem 2.5rem;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: #fff;
    transition: all var(--transition);
    font-family: inherit;
    color: var(--text-main);
}
.search-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12); }
.search-icon { position: absolute; left: 0.85rem; color: var(--text-muted); font-size: 0.95rem; pointer-events: none; }
.search-clear { position: absolute; right: 0.75rem; color: var(--text-muted); text-decoration: none; font-size: 1rem; visibility: hidden; }
.search-input:not(:placeholder-shown) + .search-clear { visibility: visible; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.info-text { color: var(--text-muted); font-size: 0.8rem; display: block; margin-top: 0.4rem; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .main-content { padding: 1.75rem 2rem; }
}

@media (max-width: 768px) {
    body { 
        flex-direction: column; 
        height: auto; 
        overflow: visible; 
    }

    /* Sidebar: hidden off-screen, slides in on mobile */
    .sidebar {
        position: fixed;
        left: -290px;
        top: 0;
        bottom: 0;
        width: 280px;
        min-width: 280px;
        height: 100vh;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 20px rgba(0,0,0,0.25);
        padding-bottom: 5rem;
    }
    body.sidebar-active .sidebar { left: 0; }
    body.sidebar-active .sidebar-overlay { display: block; }

    /* Mobile header bar — hamburger only shows here */
    .mobile-header { display: flex; }

    .main-content { padding: 1.25rem; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .page-header .btn { width: 100%; }
    .header-top { padding: 0.75rem 1rem; margin-bottom: 1.25rem; }
    .user-info { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .pagination { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
    .menu-item { padding: 0.8rem 1rem; font-size: 0.95rem; }
}

@media (max-width: 480px) {
    .login-card { padding: 2rem 1.5rem; margin: 1rem; }
    .page-title { font-size: 1.25rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .card-value { font-size: 1.75rem; }
    .main-content { padding: 1rem; }
}

/* ── Form Grids ───────────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

@media (max-width: 768px) {
    .form-grid, .form-grid-3 {
        grid-template-columns: 1fr;
    }
}
