/* ============================================================
   EKLESIA BACKOFFICE — Design System
   Distinct from the main Eklesia app
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg:             #f0f4f8;
  --surface:        #ffffff;
  --card:           #ffffff;
  --card-hover:     #f8fafc;
  --border:         #e4e9f2;
  --border-light:   #e4e9f2;
  --accent:         #21D470;
  --accent-dim:     rgba(33,212,112,0.12);
  --accent-hover:   #1ab85e;
  --text:           #222225;
  --text-muted:     #8a9bb5;
  --text-dim:       #4a5f7a;
  --success:        #10b981;
  --success-dim:    rgba(16,185,129,0.12);
  --danger:         #ef4444;
  --danger-dim:     rgba(239,68,68,0.12);
  --warning:        #f59e0b;
  --warning-dim:    rgba(245,158,11,0.12);
  --info:           #06b6d4;
  --info-dim:       rgba(6,182,212,0.12);
  --purple:         #8b5cf6;
  --purple-dim:     rgba(139,92,246,0.12);
  --radius:         10px;
  --radius-sm:      6px;
  --transition:     all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow:         0 1px 3px rgba(21,0,137,0.05), 0 4px 16px rgba(21,0,137,0.06);
}

body.dark-mode {
  --bg:             #07101f;
  --surface:        #0d1829;
  --card:           #0d1829;
  --card-hover:     #101f35;
  --border:         #1b2d47;
  --border-light:   #1b2d47;
  --text:           #dce8f8;
  --text-muted:     #4a6180;
  --text-dim:       #7a93b5;
  --shadow:         0 2px 16px rgba(0, 0, 0, 0.35);
}

/* Logos visibility */
.bo-logo-light { display: block; }
.bo-logo-dark { display: none; }
body.dark-mode .bo-logo-light { display: none; }
body.dark-mode .bo-logo-dark { display: block; }

/* Theme Icon Buttons */
.theme-sun { display: none !important; }
.theme-moon { display: block !important; }
body.dark-mode .theme-sun { display: block !important; }
body.dark-mode .theme-moon { display: none !important; }

.theme-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}
.theme-btn:hover { background: var(--card); color: var(--text); }
.theme-btn i { width: 16px !important; height: 16px !important; flex-shrink: 0; }


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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

/* Left panel — branding */
.login-brand {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.login-brand::before {
  content: '';
  position: absolute;
  top: -100px; left: -100px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(33,212,112,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.login-brand-logo {
  margin-bottom: 60px;
}

.login-brand-logo img {
  max-width: 140px;
  height: auto;
}

.login-brand h1 {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 20px;
  letter-spacing: -0.03em;
  color: var(--text);
}

.login-brand p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.7;
  max-width: 380px;
  margin-bottom: 50px;
}

.login-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 380px;
}

.login-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.login-stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}

.login-stat-label { font-size: 12px; color: var(--text-muted); }

/* Right panel — form */
.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  background: var(--bg);
}

.login-form-box {
  width: 100%;
  max-width: 400px;
}

.login-form-box h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-form-box .login-sub {
  color: var(--text-muted);
  margin-bottom: 40px;
  font-size: 14px;
}

/* ============================================================
   DASHBOARD SHELL
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
}

.sidebar-logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-operator {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.op-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-hover);
  flex-shrink: 0;
}

.op-name { font-size: 13px; font-weight: 600; }
.op-role { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

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

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 0;
  transition: all var(--transition);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 2px solid transparent;
  position: relative;
}

.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: #0e9448; border-left-color: var(--accent); }
.nav-item i { opacity: 0.7; flex-shrink: 0; }
.nav-item.active i { opacity: 1; }

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

/* Main area */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 58px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
}

.topbar-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* Sections */
.section { display: none; }
.section.active { display: block; }

/* ============================================================
   SHARED COMPONENTS
   ============================================================ */

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--border-light); }

.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.stat-sub { font-size: 12px; color: var(--text-muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(33,212,112,0.2); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--card); color: var(--text); }

.btn-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.btn-success:hover { background: rgba(16,185,129,0.2); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
}
.badge-active   { background: var(--success-dim); color: var(--success); }
.badge-trial    { background: var(--info-dim);    color: var(--info); }
.badge-expired  { background: var(--danger-dim);  color: var(--danger); }
.badge-suspended{ background: rgba(100,116,139,0.15); color: #94a3b8; }
.badge-admin    { background: var(--accent-dim);  color: var(--accent); }
.badge-support  { background: var(--purple-dim);  color: var(--purple); }
.badge-info     { background: var(--info-dim);    color: var(--info); }
.badge-warning  { background: var(--warning-dim); color: var(--warning); }
.badge-success  { background: var(--success-dim); color: var(--success); }
.badge-critical { background: var(--danger-dim);  color: var(--danger); }

/* Tables */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.table-title { font-size: 14px; font-weight: 600; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 11px 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

td {
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-dim);
  vertical-align: middle;
}

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: 0.04em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-textarea { resize: vertical; min-height: 80px; }
.form-select option { background: var(--surface); }

/* Search input */
.search-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 36px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  width: 240px;
  transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--accent); }
.search-wrap { position: relative; }
.search-wrap i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 15px; height: 15px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* Toasts */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 1000; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 340px;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--info); }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title { font-size: 18px; font-weight: 700; }
.section-sub   { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Expiring warning row */
tr.exp-soon td { background: rgba(245,158,11,0.04); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Mobile overlay backing */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
}
.hamburger-btn:hover { color: var(--text); }

.mobile-close-btn {
  display: none;
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  z-index: 10;
}
.mobile-close-btn:hover { color: var(--text); background: var(--card-hover); }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .shell { grid-template-columns: 1fr; }
  
  /* Sidebar off-canvas transform */
  .sidebar { 
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
}

body:has(.sidebar.mobile-open) .sidebar-overlay {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 900px) {
  .hamburger-btn { display: flex; }
  .mobile-close-btn { display: flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .table-wrap {
    overflow-x: auto;
  }
  th, td { white-space: nowrap; }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .stat-card {
    padding: 14px 12px;
  }
}

/* ============================================================
   CUSTOMER SUPPORT CENTER
   ============================================================ */
.su-wrap {
  display: flex;
  height: calc(100vh - 270px);
  min-height: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.su-left {
  width: 320px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  flex-shrink: 0;
}

.su-filters {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 6px;
}
.su-filter-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
}
.su-filter-btn.active { background: var(--success-dim); border-color: var(--success); color: var(--success); }

.su-list { flex: 1; overflow-y: auto; }
.su-list::-webkit-scrollbar { width: 4px; }
.su-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.su-chat-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
  position: relative;
}
.su-chat-item:hover { background: var(--bg); }
.su-chat-item.active { background: var(--success-dim); }

.su-chat-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.su-chat-church { font-size: 13.5px; font-weight: 700; color: var(--text); }
.su-chat-time { font-size: 11.5px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.su-chat-preview { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90%; }
.su-unread-dot {
  position: absolute; top: 50%; right: 16px; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}

.su-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.su-chat-header {
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.su-chat-title { font-size: 15px; font-weight: 700; color: var(--text); }
.su-chat-subtitle { font-size: 12px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

.su-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.su-reply-row {
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}
.su-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: inherit; font-size: 13.5px;
  background: var(--bg); color: var(--text);
  outline: none; resize: none; min-height: 42px; max-height: 120px;
}
.su-input:focus { border-color: var(--accent); background: var(--surface); }

/* Bubbles */
.chat-bubble {
  max-width: 80%;
  padding: 11px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
}
.bubble-church {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.bubble-support {
  align-self: flex-end;
  background: var(--accent-dim);
  color: #0e9448;
  border-bottom-right-radius: 4px;
}
body.dark-mode .bubble-support { color: var(--accent); }
.bubble-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  display: block;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

.sc-day-sep { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; margin: 8px 0; }
.sc-day-sep::before, .sc-day-sep::after { content:''; flex:1; height:1px; background:var(--border); }

