/* Module-specific UI patterns — tabs, drawers, toggles, group cards, etc. */

/* ─── Module Toolbar ─── */
.module-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-elevated);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm), 0 1px 0 rgba(255, 255, 255, 0.55) inset;
}

.toolbar-search {
  flex: 1;
  min-width: 220px;
  max-width: 320px;
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: var(--text-sm);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.toolbar-search:focus {
  outline: none;
  border-color: rgba(201, 162, 39, 0.55);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.toolbar-select {
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: var(--text-sm);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.toolbar-select:focus {
  outline: none;
  border-color: rgba(201, 162, 39, 0.55);
}

.toolbar-spacer { flex: 1; }

/* ─── Filter Tabs ─── */
.filter-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-bg-subtle);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--space-2);
  background: var(--color-bg-elevated);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm), 0 1px 0 rgba(255, 255, 255, 0.55) inset;
}

.filter-tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.filter-tab:hover { color: var(--color-text); }

.filter-tab.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.filter-tab .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-full);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
}

.filter-tab.is-active .tab-count {
  background: var(--color-accent-soft);
  color: #7a6218;
}

/* ─── Profile Drawer ─── */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 28, 0.4);
  z-index: 300;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.drawer-backdrop.is-visible {
  opacity: 1;
}

body.drawer-open .drawer-backdrop {
  display: block;
}

.drawer {
  position: fixed;
  top: 0;
  right: -480px;
  width: 440px;
  max-width: 100vw;
  height: 100vh;
  z-index: 301;
  background: var(--color-bg-elevated);
  border-left: var(--border-subtle);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transition: right var(--transition-base);
  overflow: hidden;
}

.drawer.is-open {
  right: 0;
}

.drawer-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-shrink: 0;
}

.drawer-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-family: var(--font-display);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.drawer-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a2824 0%, #141210 100%);
  color: #f5f0e8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-xl);
  border: 3px solid rgba(201, 162, 39, 0.4);
  margin-bottom: var(--space-4);
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(20, 22, 28, 0.15);
}

.drawer-field {
  margin-bottom: var(--space-4);
}

.drawer-field-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.drawer-field-value {
  font-size: var(--text-sm);
  color: var(--color-text);
}

.drawer-section {
  padding-top: var(--space-5);
  margin-top: var(--space-5);
  border-top: var(--border-subtle);
}

.drawer-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-4);
}

.drawer-actions {
  padding: var(--space-4) var(--space-6);
  border-top: var(--border-subtle);
  display: flex;
  gap: var(--space-3);
  flex-shrink: 0;
  background: var(--color-bg);
}

/* ─── Toggle Switches ─── */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.toggle-wrap:hover {
  background: var(--color-bg-subtle);
}

.toggle-label {
  font-size: var(--text-sm);
  color: var(--color-text);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(26, 29, 36, 0.18);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-slider {
  background: var(--color-accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ─── Permission Groups ─── */
.permission-panel {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: var(--space-6);
  align-items: start;
}

.role-list {
  list-style: none;
  margin: 0;
  padding: var(--space-2);
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  border: var(--border-subtle);
  box-shadow: var(--shadow-md);
}

.role-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.role-item:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.role-item.is-active {
  background: var(--color-accent-soft);
  color: #7a6218;
  font-weight: 600;
}

.role-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
  flex-shrink: 0;
}

.role-item.is-active .role-dot {
  background: var(--color-accent);
}

.permission-group {
  margin-bottom: var(--space-5);
}

.permission-group-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: var(--space-3) var(--space-4) var(--space-2);
}

/* ─── Life Group Cards ─── */
.group-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}

.group-card {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  border: var(--border-subtle);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.group-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-royal), var(--color-accent));
}

.group-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.group-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.group-card-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0 0 var(--space-1);
}

.group-card-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.group-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.group-stat {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  border: 1px solid rgba(26, 29, 36, 0.06);
  box-shadow: 0 1px 2px rgba(20, 22, 28, 0.04) inset;
}

.group-stat-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-accent-ink);
}

.group-stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.group-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* ─── Stage Badges ─── */
.stage-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
}

.stage-sunday-life { background: var(--color-info-soft); color: var(--color-info); }
.stage-encounter   { background: var(--color-warning-soft); color: var(--color-warning); }
.stage-dt          { background: var(--color-royal-soft); color: var(--color-royal); }
.stage-timothy     { background: var(--color-accent-soft); color: #7a6218; }

/* Stage checkmarks in processes table */
.stage-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
}

.stage-check.done    { background: var(--color-accent-soft); color: var(--color-accent-ink); border: 1px solid rgba(201, 162, 39, 0.28); }
.stage-check.pending { background: var(--color-bg-subtle); color: var(--color-text-muted); }

/* ─── VIP Follow-up Badges ─── */
.followup-new        { background: var(--color-info-soft); color: var(--color-info); }
.followup-contacted  { background: var(--color-warning-soft); color: var(--color-warning); }
.followup-invited-lg { background: var(--color-royal-soft); color: var(--color-royal); }
.followup-promoted   { background: var(--color-accent-soft); color: var(--color-accent-ink); }

/* ─── Inline Modal (Confirm) ─── */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.confirm-modal-overlay[hidden] { display: none !important; }

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 22, 28, 0.5);
  backdrop-filter: blur(4px);
}

.confirm-dialog {
  position: relative;
  z-index: 1;
  max-width: 420px;
  width: 100%;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  border: var(--border-subtle);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.25s ease;
  overflow: hidden;
}

/* ─── Form inline fields (within admin cards) ─── */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-section {
  margin-bottom: var(--space-8);
}

.form-section-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: var(--border-subtle);
}

/* ─── Table action buttons ─── */
.action-btn-group {
  display: flex;
  gap: var(--space-2);
  flex-wrap: nowrap;
}

/* ─── Stats mini row ─── */
.stats-mini {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.stat-mini {
  position: relative;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  border: var(--border-subtle);
  box-shadow: var(--shadow-md), 0 1px 0 rgba(255, 255, 255, 0.55) inset;
  padding: var(--space-5) var(--space-4);
}

.stat-mini::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, var(--color-accent), rgba(201, 162, 39, 0.25));
  opacity: 0.9;
}

.stat-mini-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1;
  margin-bottom: var(--space-1);
  color: var(--color-accent-ink);
  letter-spacing: -0.02em;
}

.stat-mini-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

/* ─── Settings tabs ─── */
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-bg-subtle);
  margin-bottom: var(--space-8);
}

.settings-tab {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.settings-tab:hover { color: var(--color-text); }

.settings-tab.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.settings-panel { display: none; }
.settings-panel.is-active { display: block; }

/* ─── Responsive adjustments ─── */
@media (max-width: 768px) {
  .permission-panel {
    grid-template-columns: 1fr;
  }

  .drawer {
    width: 100%;
    right: -100%;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .group-cards {
    grid-template-columns: 1fr;
  }

  .stats-mini {
    grid-template-columns: repeat(2, 1fr);
  }
}
