/* ============================================================
   Church Manager — Custom Styles
   ============================================================ */

:root {
    /* Brand Colors */
    --cm-primary:       #2c3e7a;
    --cm-primary-light: #3d54a8;
    --cm-primary-dark:  #1e2c5f;
    --cm-secondary:     #5d6fc5;
    --cm-accent:        #f0a500;
    --cm-gold:          #f0a500;

    /* Sidebar */
    --sidebar-width:       260px;
    --sidebar-collapsed:   72px;
    --sidebar-bg:          #1a2355;
    --sidebar-text:        rgba(255,255,255,.75);
    --sidebar-text-active: #ffffff;
    --sidebar-hover-bg:    rgba(255,255,255,.08);
    --sidebar-active-bg:   rgba(255,255,255,.15);
    --sidebar-icon:        rgba(255,255,255,.55);

    /* Layout */
    --topnav-height: 60px;
    --content-bg:    #f0f4f8;
    --card-border:   rgba(0,0,0,.08);

    /* Text */
    --text-primary:   #1a202c;
    --text-secondary: #64748b;
    --text-muted:     #94a3b8;

    /* Transitions */
    --transition: all .25s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--content-bg);
    color: var(--text-primary);
    font-size: .875rem;
    line-height: 1.6;
    margin: 0;
}

/* ── Layout Wrapper ── */
.wrapper {
    min-height: 100vh;
}

.main-content {
    min-height: 100vh;
    background: var(--content-bg);
    overflow-x: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    background-image: linear-gradient(180deg, #1a2355 0%, #0f1635 100%);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: var(--transition);
    z-index: 1030;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    min-height: 70px;
}

.brand-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--cm-accent), #e8920a);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(240,165,0,.35);
}

.brand-text { flex: 1; overflow: hidden; }
.brand-name { display: block; color: #fff; font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-version { display: block; color: rgba(255,255,255,.4); font-size: .7rem; }

/* User Info */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: rgba(255,255,255,.05);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cm-secondary), var(--cm-primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: .875rem;
    flex-shrink: 0;
}

.user-info { overflow: hidden; flex: 1; }
.user-name { display: block; color: #fff; font-weight: 600; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; color: rgba(255,255,255,.45); font-size: .7rem; white-space: nowrap; }

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,.07);
    margin: 4px 0;
}

/* Nav */
.sidebar-nav { flex: 1; padding: 8px 0; }

.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }

.nav-section-title {
    padding: 16px 18px 4px;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: rgba(255,255,255,.35);
    text-transform: uppercase;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: var(--sidebar-text);
    border-radius: 0;
    transition: var(--transition);
    position: relative;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
    margin: 1px 8px;
    border-radius: 8px;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--cm-accent);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    width: 20px;
    text-align: center;
    color: var(--sidebar-icon);
    flex-shrink: 0;
    font-size: .85rem;
    transition: var(--transition);
}

.sidebar-nav .nav-link:hover .nav-icon,
.sidebar-nav .nav-link.active .nav-icon {
    color: var(--cm-accent);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: rgba(220,53,69,.15);
    color: rgba(255,120,120,.9);
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(220,53,69,.25);
    color: #ff6b6b;
}

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

.sidebar-close { display: none; color: rgba(255,255,255,.7) !important; }

/* ── Top Navbar ── */
.top-navbar {
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    min-height: var(--topnav-height);
    padding: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    z-index: 1020;
}

.avatar-sm {
    width: 34px;
    height: 34px;
    font-size: .85rem;
}

/* ── Content Area ── */
.content-wrapper {
    padding: 1.5rem;
}

/* ── Cards ── */
.card {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    border-radius: 12px 12px 0 0 !important;
    padding: 1rem 1.25rem;
}

/* ── Stat Cards ── */
.stat-card {
    border-radius: 14px;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
    border: none;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12) !important;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: .78rem;
    font-weight: 500;
    opacity: .75;
}

.stat-card .stat-change {
    font-size: .73rem;
    font-weight: 600;
}

/* Stat card variants */
.stat-primary   { background: linear-gradient(135deg, var(--cm-primary) 0%, var(--cm-secondary) 100%); color: #fff; }
.stat-success   { background: linear-gradient(135deg, #1a8a6e 0%, #26c48f 100%); color: #fff; }
.stat-danger    { background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%); color: #fff; }
.stat-warning   { background: linear-gradient(135deg, #d68910 0%, #f39c12 100%); color: #fff; }
.stat-info      { background: linear-gradient(135deg, #1a6a9a 0%, #2980b9 100%); color: #fff; }

.stat-primary .stat-icon   { background: rgba(255,255,255,.2); color: #fff; }
.stat-success .stat-icon   { background: rgba(255,255,255,.2); color: #fff; }
.stat-danger .stat-icon    { background: rgba(255,255,255,.2); color: #fff; }
.stat-warning .stat-icon   { background: rgba(255,255,255,.2); color: #fff; }
.stat-info .stat-icon      { background: rgba(255,255,255,.2); color: #fff; }

/* ── Tables ── */
.table { font-size: .83rem; }
.table th { font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); background: #f8fafc; }
.table > :not(caption) > * > * { padding: .65rem .875rem; }

.table-hover tbody tr:hover { background-color: #f0f4ff; cursor: pointer; }

/* ── Buttons ── */
.btn { font-size: .82rem; font-weight: 500; border-radius: 8px; }
.btn-sm { font-size: .77rem; }
.btn-primary { background-color: var(--cm-primary); border-color: var(--cm-primary); }
.btn-primary:hover { background-color: var(--cm-primary-dark); border-color: var(--cm-primary-dark); }

/* ── Forms ── */
.form-control, .form-select {
    font-size: .83rem;
    border-radius: 8px;
    border-color: #e2e8f0;
    padding: .5rem .875rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--cm-secondary);
    box-shadow: 0 0 0 .2rem rgba(93,111,197,.15);
}

.form-label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: .35rem; }

/* ── Badges ── */
.badge { font-size: .72rem; font-weight: 600; border-radius: 6px; padding: .3em .6em; }

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.page-header .breadcrumb {
    font-size: .78rem;
    margin: 0;
}

/* ── Footer ── */
.app-footer {
    background: #fff;
    border-top: 1px solid var(--card-border);
    padding: .75rem 1.5rem;
    text-align: center;
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--cm-primary-dark) 0%, var(--cm-primary) 50%, var(--cm-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: rgba(255,255,255,.03);
    top: -200px;
    right: -150px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255,255,255,.04);
    bottom: -100px;
    left: -100px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 25px 60px rgba(0,0,0,.3);
    position: relative;
    z-index: 1;
}

.login-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--cm-primary), var(--cm-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.8rem;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 24px rgba(44,62,122,.35);
}

/* ── Utilities ── */
.text-primary-dark { color: var(--cm-primary) !important; }
.bg-primary-subtle { background-color: rgba(44,62,122,.1) !important; }
.text-primary { color: var(--cm-primary) !important; }
.border-primary { border-color: var(--cm-primary) !important; }

.cursor-pointer { cursor: pointer; }
.fs-13 { font-size: .8125rem; }
.fs-12 { font-size: .75rem; }
.gap-2 { gap: .5rem; }

/* ── Responsive ── */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: -280px;
        height: 100%;
        transition: left .3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .sidebar-close {
        display: block !important;
    }

    .main-content {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── Animations ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp .3s ease forwards; }

/* Stagger children */
.stagger-children > * { opacity: 0; animation: fadeInUp .3s ease forwards; }
.stagger-children > *:nth-child(1) { animation-delay: .05s; }
.stagger-children > *:nth-child(2) { animation-delay: .1s; }
.stagger-children > *:nth-child(3) { animation-delay: .15s; }
.stagger-children > *:nth-child(4) { animation-delay: .2s; }
.stagger-children > *:nth-child(5) { animation-delay: .25s; }

/* ── Input Group Icons ── */
.input-icon-group { position: relative; }
.input-icon-group .input-icon {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 5;
}
.input-icon-group .form-control { padding-left: 2.5rem; }
