/* ============================================
   SOUTHFIT GYM — DESIGN SYSTEM
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Colors */
  --bg-base:        #0a0a0f;
  --bg-surface:     #111118;
  --bg-card:        #16161f;
  --bg-card-hover:  #1e1e2a;
  --bg-input:       #1a1a25;
  --border:         #2a2a3e;
  --border-light:   #333348;

  /* Accent */
  --accent:         #00d4aa;
  --accent-dim:     rgba(0, 212, 170, 0.12);
  --accent-glow:    rgba(0, 212, 170, 0.3);
  --accent-alt:     #6c63ff;
  --accent-alt-dim: rgba(108, 99, 255, 0.12);

  /* Text */
  --text-primary:   #f0f0f8;
  --text-secondary: #8888aa;
  --text-muted:     #55556a;

  /* Status */
  --green:          #00d4aa;
  --green-dim:      rgba(0, 212, 170, 0.12);
  --red:            #ff4d6d;
  --red-dim:        rgba(255, 77, 109, 0.12);
  --yellow:         #ffb347;
  --yellow-dim:     rgba(255, 179, 71, 0.12);
  --blue:           #4d9fff;
  --blue-dim:       rgba(77, 159, 255, 0.12);

  /* Typography */
  --font:           'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --fs-xs:          11px;
  --fs-sm:          13px;
  --fs-base:        14px;
  --fs-md:          16px;
  --fs-lg:          18px;
  --fs-xl:          22px;
  --fs-2xl:         28px;
  --fs-3xl:         36px;

  /* Spacing */
  --sp-1:    4px;
  --sp-2:    8px;
  --sp-3:    12px;
  --sp-4:    16px;
  --sp-5:    20px;
  --sp-6:    24px;
  --sp-8:    32px;
  --sp-10:   40px;
  --sp-12:   48px;
  --sp-16:   64px;

  /* Radius */
  --r-sm:    6px;
  --r-md:    10px;
  --r-lg:    14px;
  --r-xl:    20px;
  --r-full:  9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-accent: 0 0 20px var(--accent-glow);

  /* Transitions */
  --t-fast:    0.15s ease;
  --t-base:    0.25s ease;
  --t-slow:    0.4s ease;

  /* Layout */
  --sidebar-w: 240px;
  --header-h:  64px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: var(--font);
  border: none;
  outline: none;
  background: none;
}

input, textarea, select {
  font-family: var(--font);
  font-size: var(--fs-base);
}

img {
  display: block;
  max-width: 100%;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Layout Shell ── */
#app {
  display: flex;
  min-height: 100vh;
}

.app-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--t-base);
}

.page-wrapper {
  flex: 1;
  padding: var(--sp-8);
  padding-top: calc(var(--header-h) + var(--sp-6));
  overflow-y: auto;
}

/* ── Typography ── */
h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.5px; }
h2 { font-size: var(--fs-xl);  font-weight: 600; }
h3 { font-size: var(--fs-lg);  font-weight: 600; }
h4 { font-size: var(--fs-md);  font-weight: 600; }

.text-xs      { font-size: var(--fs-xs); }
.text-sm      { font-size: var(--fs-sm); }
.text-muted   { color: var(--text-secondary); }
.text-accent  { color: var(--accent); }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 18px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: all var(--t-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--t-fast);
}

.btn:hover::after {
  background: rgba(255,255,255,0.05);
}

.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover {
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.btn-ghost {
  color: var(--text-secondary);
  padding: 6px 12px;
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 77, 109, 0.3);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

.btn-sm {
  padding: 5px 12px;
  font-size: var(--fs-xs);
  border-radius: var(--r-sm);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Form Elements ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}

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

.form-input::placeholder { color: var(--text-muted); }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  transition: border-color var(--t-fast);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-4) 0;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-8);
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-top: var(--sp-1);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16);
  color: var(--text-muted);
  text-align: center;
  gap: var(--sp-3);
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.4;
}

/* ── Loading ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.animate-fade    { animation: fadeIn 0.3s ease both; }
.animate-scale   { animation: fadeInScale 0.3s ease both; }
.animate-slide-r { animation: slideInRight 0.3s ease both; }

/* ── Utilities ── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1  { gap: var(--sp-1); }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }
.gap-6  { gap: var(--sp-6); }
.gap-8  { gap: var(--sp-8); }
.w-full { width: 100%; }
.mt-2   { margin-top: var(--sp-2); }
.mt-4   { margin-top: var(--sp-4); }
.mt-6   { margin-top: var(--sp-6); }
.mb-4   { margin-bottom: var(--sp-4); }
.mb-6   { margin-bottom: var(--sp-6); }
.hidden { display: none !important; }

/* ── Mobile Bottom Nav ── */
.mobile-bottom-nav {
  display: none; /* Hidden by default, shown via media query */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
  z-index: 1000;
  justify-content: space-around;
  align-items: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.mobile-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  transition: all var(--t-fast);
  min-width: 60px;
  -webkit-tap-highlight-color: transparent;
}

.mobile-tab-icon {
  font-size: 22px;
  line-height: 1;
}

.mobile-tab-label {
  font-size: 10px;
  letter-spacing: 0.2px;
}

.mobile-tab.active {
  color: var(--accent);
}

.mobile-tab.active .mobile-tab-icon {
  transform: scale(1.1);
}

.mobile-tab:active {
  transform: scale(0.92);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .main-content { margin-left: 0; }
  .page-wrapper { padding: var(--sp-4); padding-top: calc(var(--header-h) + var(--sp-4)); }
  .form-grid { grid-template-columns: 1fr; }
  .main-content { overflow-x: auto; }

  /* Text overflow helpers */
  .member-cell-sub { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  td, th { font-size: var(--fs-xs); padding: var(--sp-2) var(--sp-2) !important; }
  .member-cell-name { font-size: var(--fs-sm); }
  .avatar-md { width: 32px; height: 32px; font-size: 11px; }

  /* Show bottom nav for roles with has-mobile-nav class */
  .has-mobile-nav .mobile-bottom-nav {
    display: flex;
  }

  /* Add padding at bottom for pages so content isn't hidden behind bottom nav */
  .has-mobile-nav .page-wrapper {
    padding-bottom: 80px;
  }

  /* Make buttons touch-friendly */
  .has-mobile-nav .btn {
    min-height: 44px;
    font-size: var(--fs-base);
  }

  /* KPI grid: 2 columns on mobile */
  .has-mobile-nav .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--sp-3) !important;
  }

  .has-mobile-nav .kpi-card {
    padding: var(--sp-3) !important;
  }

  .has-mobile-nav .kpi-value {
    font-size: var(--fs-xl) !important;
  }

  /* Dashboard grid: single column */
  .has-mobile-nav .dashboard-grid {
    grid-template-columns: 1fr !important;
  }

  /* Cards more compact */
  .has-mobile-nav .card {
    padding: var(--sp-4);
  }

  /* Page header compact */
  .has-mobile-nav .page-header {
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
  }

  .has-mobile-nav .page-title {
    font-size: var(--fs-xl);
  }

  /* Hide unnecessary elements */
  .has-mobile-nav .hide-mobile,
  .has-mobile-nav .kpi-trend {
    display: none !important;
  }

  /* Sidebar footer: push above bottom nav so logout isn't hidden */
  .has-mobile-nav .sidebar-footer {
    padding-bottom: 72px;
  }
}
