/* ══════════════════════════════════════════════════════════════════
   GymsFlow — Shared UI Core Components
   Consolidated from 18+ page-specific CSS files
   Single source of truth for reusable components
   ══════════════════════════════════════════════════════════════════ */

/* ==========================================================================
   1. HEADER ACTION BUTTONS (Rule C-53)
   Previously duplicated across 18 page CSS files.
   Desktop: pill buttons with text + icon
   Mobile (<=768px): handled by gym-dashboard-overrides.css (38px icon boxes)
   ========================================================================== */
.btn-header-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-full, 9999px);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  border: none;
}

.btn-header-action svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-header-secondary {
  background: var(--bg-card-subtle, #f8fafc);
  color: var(--text-main, #0F172A);
  border: 1px solid var(--border-light, #e2e8f0);
}

.btn-header-secondary:hover {
  background: var(--bg-card, #ffffff);
  border-color: var(--border-focus, var(--primary, #2563EB));
  color: var(--primary, #2563EB);
  transform: translateY(-1px);
  box-shadow: var(--shadow-subtle, 0 1px 3px rgba(0,0,0,0.05));
}

.btn-header-primary {
  background: var(--primary, #2563EB);
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

.btn-header-primary:hover {
  background: var(--primary-hover, #1d4ed8);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.38);
  color: #ffffff !important;
}

/* ==========================================================================
   2. HORIZONTAL CHIP / FILTER SCROLL STRIP
   Previously duplicated as .inv-chip-scroll, .att-chip-scroll,
   .members-chip-scroll, .enquiries-chips-scroll, .plans-chip-scroll, etc.
   Usage: <div class="gf-chip-scroll"> or add gf-chip-scroll alongside
   existing page-prefixed class.
   ========================================================================== */
.gf-chip-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.gf-chip-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 16px 6px 2px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.gf-chip-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.gf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-full, 9999px);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: var(--bg-card, #ffffff);
  color: var(--text-muted, #64748b);
  border: 1px solid var(--border-light, #e2e8f0);
  transition: all var(--transition-fast, 0.15s ease);
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
  cursor: pointer;
}

.gf-chip:hover {
  background: var(--bg-card-subtle, #f8fafc);
  color: var(--text-main, #0F172A);
  border-color: var(--border-focus, #cbd5e1);
  transform: translateY(-1px);
}

.gf-chip.active {
  background: var(--text-main, #0F172A);
  color: #ffffff;
  border-color: var(--text-main, #0F172A);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.gf-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gf-chip-dot.green  { background: var(--accent-green, #10B981); }
.gf-chip-dot.amber  { background: var(--accent-amber, #F59E0B); }
.gf-chip-dot.rose   { background: var(--accent-rose, #EF4444); }
.gf-chip-dot.blue   { background: var(--primary, #2563EB); }
.gf-chip-dot.purple { background: var(--accent-indigo, #6366F1); }

.gf-chip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-full, 9999px);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.gf-chip-divider {
  width: 1px;
  height: 22px;
  background: var(--border-light, #e2e8f0);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ==========================================================================
   3. KPI GRID & KPI CARDS (Standardized 4-Stage Responsive)
   Base structural rules. Page-specific colors / icons stay in page CSS.
   Stage 1 (>=1201px): repeat(auto-fit, minmax(220px, 1fr))
   Stage 2 (901–1200px): 4-col
   Stage 3 (481–900px): 2-col
   Stage 4 (<=480px): auto-fit single column
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-grid a.card.kpi-card {
  text-decoration: none !important;
  color: inherit !important;
}

.kpi-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: var(--radius-md, 12px);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-subtle, 0 1px 3px rgba(0,0,0,0.04));
  transition: transform var(--transition-fast, 0.15s ease),
              box-shadow var(--transition-fast, 0.15s ease);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover, 0 4px 12px rgba(0,0,0,0.08));
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted, #64748B);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.kpi-value {
  font-family: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main, #0F172A);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.kpi-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm, 8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon svg {
  width: 20px;
  height: 20px;
}

/* 5-column variant (PT Plans, Nutrition Databank) */
.kpi-grid--5 {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 1200px) {
  .kpi-grid--5 { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 992px) {
  .kpi-grid--5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .kpi-grid--5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .kpi-grid--5 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   4. STATUS PILLS / BADGES (Unified Semantic)
   ========================================================================== */
.gf-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-full, 9999px);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  text-transform: capitalize;
}

.gf-status-pill--active,
.gf-status-pill--success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green, #10B981);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.gf-status-pill--warning,
.gf-status-pill--expiring {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-amber, #F59E0B);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.gf-status-pill--danger,
.gf-status-pill--expired {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-rose, #EF4444);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.gf-status-pill--info {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan, #06B6D4);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.gf-status-pill--neutral,
.gf-status-pill--inactive {
  background: rgba(100, 116, 139, 0.1);
  color: var(--accent-slate, #64748B);
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.gf-status-pill--primary {
  background: var(--primary-light, #EFF6FF);
  color: var(--primary, #2563EB);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

/* ==========================================================================
   5. TABLE RESPONSIVE WRAPPER (shared)
   ========================================================================== */
.gf-table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md, 12px);
}

.gf-table-responsive::-webkit-scrollbar {
  height: 4px;
}

.gf-table-responsive::-webkit-scrollbar-thumb {
  background: var(--border-mid, #CBD5E1);
  border-radius: 4px;
}

/* ==========================================================================
   6. FORM FIELD CORE (shared)
   ========================================================================== */
.gf-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gf-form-field label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main, #0F172A);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   7. DARK MODE COMPATIBILITY (auto-resolve via canonical tokens)
   ========================================================================== */
[data-theme="dark"] .gf-chip {
  background: var(--bg-card);
  color: var(--text-muted);
  border-color: var(--border-light);
}

[data-theme="dark"] .gf-chip:hover {
  background: var(--bg-card-subtle);
  color: var(--text-main);
}

[data-theme="dark"] .gf-chip.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

[data-theme="dark"] .kpi-card {
  background: var(--bg-card);
  border-color: var(--border-light);
}
