/* ============================================================
   ChurchOS – Custom SaaS Stylesheet
   Modern, clean SaaS dashboard aesthetic
   ============================================================ */

/* ─── CSS Variables ──────────────────────────────────────────── */
:root {
  --primary:        #4f46e5;
  --primary-dark:   #3730a3;
  --primary-light:  #ede9fe;
  --sidebar-width:  260px;
  --sidebar-collapsed-width: 70px;
  --navbar-height:  64px;
  --sidebar-bg:     #0f172a;
  --sidebar-text:   #94a3b8;
  --sidebar-hover:  #1e293b;
  --sidebar-active: #1e293b;
  --body-bg:        #f1f5f9;
  --card-bg:        #ffffff;
  --card-border:    #e2e8f0;
  --text-main:      #1e293b;
  --text-muted:     #64748b;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:      0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.05);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.05);
  --radius:         12px;
  --radius-sm:      8px;
  --transition:     all .2s ease;
}

/* ─── Base Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: .9rem;
  background: var(--body-bg);
  color: var(--text-main);
  margin: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }
img { max-width: 100%; }

/* ─── Layout Wrapper ─────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  transition: var(--transition);
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.04);
}

/* Sidebar Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: var(--navbar-height);
  overflow: hidden;
}

.brand-logo { flex-shrink: 0; }

.church-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
}

.brand-info {
  flex: 1;
  overflow: hidden;
  transition: var(--transition);
}

.brand-name {
  display: block;
  color: #f1f5f9;
  font-weight: 600;
  font-size: .875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 4px;
  padding: 1px 6px;
  margin-top: 2px;
}

.sidebar-collapse-btn {
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: var(--transition);
  margin-left: auto;
}
.sidebar-collapse-btn:hover { color: #f1f5f9; background: var(--sidebar-hover); }

/* Sidebar Nav */
.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  margin: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: 12px 20px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .15s;
}

.nav-item {}

.nav-item .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  border-radius: 8px;
  margin: 1px 8px;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item .nav-link:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav-item.active .nav-link {
  background: var(--primary);
  color: #ffffff;
}

.nav-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.nav-text {
  font-size: .845rem;
  font-weight: 500;
  flex: 1;
  transition: opacity .15s, width .2s;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  overflow: hidden;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-details {
  overflow: hidden;
  transition: var(--transition);
}

.user-name {
  display: block;
  color: #e2e8f0;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: block;
  color: #64748b;
  font-size: .7rem;
  white-space: nowrap;
}

.btn-logout {
  background: transparent;
  border: none;
  color: #64748b;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
  flex-shrink: 0;
}
.btn-logout:hover { color: #ef4444; background: rgba(239,68,68,.1); }

/* ─── Sidebar Collapsed State ───────────────────────────────── */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .brand-info,
.sidebar.collapsed .user-details,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

.sidebar.collapsed .nav-item .nav-link {
  justify-content: center;
  padding: 9px;
  margin: 1px 6px;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 20px 8px 16px;
}

.sidebar.collapsed .sidebar-collapse-btn { display: none; }

.sidebar.collapsed .sidebar-footer {
  justify-content: center;
}

.sidebar.collapsed .btn-logout { margin: 0; }

/* ─── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left .2s ease;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

/* ─── Top Navbar ─────────────────────────────────────────────── */
.top-navbar {
  height: var(--navbar-height);
  background: #ffffff;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: var(--transition);
}
.mobile-menu-btn:hover { background: var(--body-bg); color: var(--text-main); }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.icon-btn:hover { background: var(--body-bg); color: var(--text-main); }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  font-size: .6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-dropdown { min-width: 290px; border: 1px solid var(--card-border); }

.notif-item {
  display: flex !important;
  align-items: flex-start !important;
  gap: 10px;
  padding: 10px 16px !important;
  white-space: normal !important;
}

.user-btn {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: var(--transition);
}
.user-btn:hover { background: var(--body-bg); }
.user-btn::after { display: none; } /* Remove BS dropdown caret */

.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: .78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name-nav {
  font-size: .845rem;
  font-weight: 500;
  color: var(--text-main);
}

/* ─── Page Content Area ──────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ─── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: default;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon-wrap.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon-wrap.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon-wrap.green  { background: #dcfce7; color: #16a34a; }
.stat-icon-wrap.orange { background: #ffedd5; color: #ea580c; }

.stat-info { flex: 1; }

.stat-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-trend {
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.stat-trend.up   { background: #dcfce7; color: #16a34a; }
.stat-trend.down { background: #fee2e2; color: #dc2626; }

/* ─── Content Cards ──────────────────────────────────────────── */
.content-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header-custom {
  padding: 18px 22px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header-custom h6 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
}

.card-body-custom { padding: 22px; }

/* ─── Chart Containers ───────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 280px;
}

/* ─── Tables ─────────────────────────────────────────────────── */
.table-custom {
  font-size: .845rem;
}
.table-custom thead th {
  font-size: .73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-color: var(--card-border);
  padding: 12px 16px;
  background: #f8fafc;
}
.table-custom tbody td {
  padding: 12px 16px;
  border-color: #f1f5f9;
  vertical-align: middle;
  color: var(--text-main);
}
.table-custom tbody tr { transition: background .1s; }
.table-custom tbody tr:hover { background: #f8fafc; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge-status {
  font-size: .7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.badge-pending   { background: #fef3c7; color: #d97706; }
.badge-fulfilled { background: #dcfce7; color: #16a34a; }
.badge-cancelled { background: #fee2e2; color: #dc2626; }
.badge-active    { background: #dbeafe; color: #2563eb; }
.badge-planning  { background: #f3e8ff; color: #9333ea; }
.badge-completed { background: #dcfce7; color: #16a34a; }
.badge-upcoming  { background: #dbeafe; color: #2563eb; }
.badge-ongoing   { background: #dcfce7; color: #16a34a; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-sm-icon {
  padding: 5px 8px;
  font-size: .8rem;
  border-radius: 6px;
  line-height: 1;
}

/* ─── Forms ──────────────────────────────────────────────────── */
.form-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 5px;
}

.form-control, .form-select {
  font-size: .875rem;
  border-color: #cbd5e1;
  border-radius: var(--radius-sm);
  padding: .46rem .85rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ─── Progress ───────────────────────────────────────────────── */
.progress-custom {
  height: 8px;
  border-radius: 4px;
  background: #e2e8f0;
  overflow: hidden;
}
.progress-bar-custom {
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  transition: width .4s ease;
}

/* ─── Page Header ────────────────────────────────────────────── */
.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.module-header h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

/* ─── Sidebar Overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ─── Login Page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.25);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.6rem;
  margin: 0 auto 14px;
}

.login-brand h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.login-brand p {
  font-size: .845rem;
  color: var(--text-muted);
  margin: 0;
}

/* ─── Pledge Card Preview ────────────────────────────────────── */
.pledge-card-preview {
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 24px;
  background: white;
  max-width: 400px;
  margin: 0 auto;
}

/* ─── Mobile Responsive ──────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    left: calc(-1 * var(--sidebar-width));
    z-index: 1100;
    box-shadow: none;
  }

  .sidebar.mobile-open {
    left: 0;
    box-shadow: 0 0 40px rgba(0,0,0,.3);
  }

  .main-content {
    margin-left: 0 !important;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .page-content { padding: 16px; }
}

@media (max-width: 575.98px) {
  .stat-value { font-size: 1.3rem; }
  .login-card { padding: 30px 24px; }
}

/* ─── Utility Helpers ────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.bg-primary   { background: var(--primary) !important; }

.rounded-custom { border-radius: var(--radius); }

.shadow-custom-sm { box-shadow: var(--shadow-sm); }
.shadow-custom-md { box-shadow: var(--shadow-md); }

.section-divider {
  border: none;
  height: 1px;
  background: var(--card-border);
  margin: 20px 0;
}

/* Avatar initials in tables */
.avatar-initials {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 3rem;
  opacity: .3;
  margin-bottom: 12px;
  display: block;
}
/*
 * ─── SIDEBAR TOGGLE CSS ──────────────────────────────────────────────────────
 * Add/replace these rules in assets/css/style.css
 *
 * Logic:
 *   Desktop: body.sidebar-collapsed → sidebar narrows to 64px icon rail,
 *            .main-content shifts left by the same amount.
 *   Mobile:  body.sidebar-open → sidebar slides in from left over an overlay.
 * ─────────────────────────────────────────────────────────────────────────────
 */

:root {
  --sidebar-w:          240px;
  --sidebar-collapsed-w: 64px;
}

/* ── Sidebar base ───────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  z-index: 200;
  overflow: hidden;
  transition: width .25s ease, transform .25s ease;
  display: flex;
  flex-direction: column;
}

/* ── Main content base ──────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  transition: margin-left .25s ease;
  min-width: 0;
}

/* ── Desktop collapsed state ────────────────────────────────── */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-w);
}
body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-w);
}

/* Hide text labels when collapsed, keep icons */
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .brand-info,
body.sidebar-collapsed .brand-badge,
body.sidebar-collapsed .user-details {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity .2s, width .2s;
}

/* Centre the icons when collapsed */
body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
body.sidebar-collapsed .nav-icon {
  margin: 0;
}
body.sidebar-collapsed .sidebar-footer {
  justify-content: center;
}
body.sidebar-collapsed .user-mini {
  justify-content: center;
}

/* ── Toggle button (always in navbar, always visible) ───────── */
.sidebar-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: .35rem .5rem;
  border-radius: 6px;
  font-size: 1.25rem;
  color: inherit;
  line-height: 1;
  transition: background .15s;
}
.sidebar-toggle-btn:hover {
  background: rgba(0, 0, 0, .06);
}

/* ── Overlay (mobile only) ──────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 199;
}
.sidebar-overlay.active {
  display: block;
}

/* ── Mobile behaviour ───────────────────────────────────────── */
@media (max-width: 991.98px) {
  .main-content {
    margin-left: 0 !important;   /* content always full-width on mobile */
  }

  .sidebar {
    transform: translateX(-100%);  /* hidden off-screen by default */
    width: var(--sidebar-w) !important;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);      /* slide in */
  }
}