/* ================================================================
   HMWorkout — components.css
   Reusable UI Components: Buttons, Cards, Forms, Badges, Modals
   ================================================================ */

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 13px 28px;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  line-height: 1;
  cursor: pointer;
  border: none;
  transition: var(--ease-spring);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
}

/* Ripple effect on all buttons */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.25) 0%, transparent 60%);
  opacity: 0;
  transform: scale(0);
  transition: transform 0.4s ease, opacity 0.4s ease;
}
.btn:active::after {
  opacity: 1;
  transform: scale(2.5);
  transition: 0s;
}

.btn-primary {
  background: var(--grad-orange);
  color: #fff;
  box-shadow: var(--shadow-orange);
}
.btn-primary:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 48px rgba(255,107,26,0.55);
}
.btn-primary:active { transform: translateY(-1px) scale(0.99); }

.btn-secondary {
  background: var(--bg-raised);
  color: var(--t-primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  background: var(--c-blue);
  color: #fff;
  border-color: var(--c-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-blue);
}

.btn-outline {
  background: transparent;
  color: var(--c-orange);
  border: 2px solid var(--c-orange);
}
.btn-outline:hover {
  background: var(--c-orange);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-orange);
}

.btn-ghost {
  background: transparent;
  color: var(--t-secondary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-raised);
  color: var(--t-primary);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--c-red);
  color: #fff;
}
.btn-danger:hover {
  background: #C02020;
  transform: translateY(-2px);
}

.btn-sm {
  padding: 9px 20px;
  font-size: var(--fs-sm);
}
.btn-lg {
  padding: 17px 40px;
  font-size: var(--fs-md);
}
.btn-xl {
  padding: 20px 52px;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--r-full);
}
.btn-icon.btn-sm { width: 36px; height: 36px; font-size: 13px; }
.btn-icon.btn-lg { width: 54px; height: 54px; font-size: 20px; }

.btn[disabled], .btn.loading {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* Loading spinner inside button */
.btn.loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: var(--s-2);
}

/* ── CARDS ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: var(--s-8);
  transition: var(--ease-smooth);
}
.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.card-glass {
  background: var(--grad-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: var(--s-8);
  transition: var(--ease-smooth);
}
.card-glass:hover {
  border-color: rgba(255,255,255,0.22);
  box-shadow: var(--shadow-xl);
  transform: translateY(-4px);
}

.card-feature {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: var(--s-8);
  transition: var(--ease-smooth);
  position: relative;
  overflow: hidden;
}
.card-feature::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--grad-orange);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}
.card-feature:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.card-feature:hover::before { transform: scaleX(1); }

.card-workout {
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: var(--ease-smooth);
}
.card-workout:hover { transform: translateY(-6px); box-shadow: var(--shadow-xl); }

/* ── FORM ELEMENTS ───────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-bottom: var(--s-5);
}

.form-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--t-secondary);
  letter-spacing: 0.02em;
}

.form-input {
  width: 100%;
  padding: 13px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-family: var(--font-body);
  color: var(--t-primary);
  transition: var(--ease-fast);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.form-input:focus {
  border-color: var(--c-blue);
  background: var(--bg-surface);
  box-shadow: 0 0 0 4px rgba(21,87,255,0.10);
}
.form-input::placeholder { color: var(--t-muted); }
.form-input.error  { border-color: var(--c-red); }
.form-input.success{ border-color: var(--c-green); }

.form-select {
  width: 100%;
  padding: 13px 40px 13px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-family: var(--font-body);
  color: var(--t-primary);
  cursor: pointer;
  transition: var(--ease-fast);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A97B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.form-select:focus {
  border-color: var(--c-blue);
  box-shadow: 0 0 0 4px rgba(21,87,255,0.10);
}

.form-error {
  font-size: var(--fs-sm);
  color: var(--c-red);
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin-top: var(--s-1);
}

.form-hint {
  font-size: var(--fs-sm);
  color: var(--t-muted);
  margin-top: var(--s-1);
}

/* OTP Input Group */
.otp-group {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
}
.otp-box {
  width: 54px;
  height: 60px;
  text-align: center;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  font-family: var(--font-display);
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  color: var(--t-primary);
  transition: var(--ease-fast);
  outline: none;
  caret-color: var(--c-blue);
}
.otp-box:focus {
  border-color: var(--c-blue);
  box-shadow: 0 0 0 4px rgba(21,87,255,0.12);
  transform: scale(1.06);
}
.otp-box.filled { border-color: var(--c-green); background: rgba(13,191,111,0.08); }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
}
.badge-blue   { background: rgba(21,87,255,0.12);  color: var(--c-blue); }
.badge-orange { background: rgba(255,107,26,0.12); color: var(--c-orange); }
.badge-green  { background: rgba(13,191,111,0.12); color: var(--c-green); }
.badge-red    { background: rgba(224,52,52,0.12);  color: var(--c-red); }
.badge-gold   { background: rgba(245,183,49,0.15); color: #C87800; }
.badge-purple { background: rgba(124,58,237,0.12); color: var(--c-purple); }
.badge-gray   { background: var(--bg-raised);       color: var(--t-secondary); }

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── AVATARS ─────────────────────────────────────────────────── */
.avatar {
  border-radius: var(--r-full);
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.avatar-sm  { width: 32px;  height: 32px; }
.avatar-md  { width: 44px;  height: 44px; }
.avatar-lg  { width: 64px;  height: 64px; }
.avatar-xl  { width: 96px;  height: 96px; }
.avatar-2xl { width: 128px; height: 128px; border-width: 3px; }

.avatar-placeholder {
  border-radius: var(--r-full);
  background: var(--grad-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  flex-shrink: 0;
}

/* ── TAGS ────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  background: var(--bg-raised);
  color: var(--t-secondary);
  border: 1px solid var(--border);
  transition: var(--ease-fast);
}
.tag:hover { background: var(--c-blue); color: #fff; border-color: var(--c-blue); }
.tag.active { background: var(--c-blue); color: #fff; border-color: var(--c-blue); }

/* ── DIVIDERS ────────────────────────────────────────────────── */
.divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: var(--s-6) 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  color: var(--t-muted);
  font-size: var(--fs-sm);
  margin: var(--s-6) 0;
}
.divider-text::before, .divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── MODALS ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  animation: fadeIn 0.25s ease;
}
.modal-box {
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  padding: var(--s-10);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleInBounce 0.4s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
}
.modal-close {
  position: absolute;
  top: var(--s-5);
  right: var(--s-5);
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--t-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--ease-fast);
  font-size: 16px;
}
.modal-close:hover { background: var(--c-red); color: #fff; border-color: var(--c-red); }

/* ── TOAST NOTIFICATIONS ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--s-6);
  right: var(--s-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  animation: toastIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.toast.hide { animation: toastOut 0.35s ease forwards; }
.toast-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.toast.success .toast-icon { background: rgba(13,191,111,0.12); color: var(--c-green); }
.toast.error   .toast-icon { background: rgba(224,52,52,0.12);  color: var(--c-red);   }
.toast.info    .toast-icon { background: rgba(21,87,255,0.12);  color: var(--c-blue);  }
.toast.warning .toast-icon { background: rgba(245,183,49,0.12); color: var(--c-gold);  }
.toast-content { flex: 1; }
.toast-title {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  color: var(--t-primary);
  margin-bottom: 2px;
}
.toast-msg { font-size: var(--fs-sm); color: var(--t-secondary); }

/* ── PROGRESS BARS ───────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-raised);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--grad-orange);
  border-radius: var(--r-full);
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
  animation: progressFill 0.8s ease;
}
.progress-fill.blue   { background: var(--grad-blue);  }
.progress-fill.green  { background: var(--grad-green); }

/* ── STEP INDICATOR ─────────────────────────────────────────── */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: var(--s-8);
  width: 100%;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}
.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 18px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step-item.done:not(:last-child)::after { background: var(--c-green); }
.step-item.active:not(:last-child)::after { background: var(--grad-blue); }

.step-dot {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--bg-raised);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--t-muted);
  z-index: 1;
  transition: var(--ease-smooth);
}
.step-item.active .step-dot {
  background: var(--grad-blue);
  border-color: var(--c-blue);
  color: #fff;
  box-shadow: 0 4px 16px rgba(21,87,255,0.4);
  transform: scale(1.1);
}
.step-item.done .step-dot {
  background: var(--c-green);
  border-color: var(--c-green);
  color: #fff;
}
.step-label {
  font-size: var(--fs-xs);
  color: var(--t-muted);
  margin-top: var(--s-2);
  text-align: center;
  font-weight: var(--fw-medium);
}
.step-item.active .step-label { color: var(--c-blue); font-weight: var(--fw-semibold); }
.step-item.done  .step-label  { color: var(--c-green); }

@media (max-width: 640px) {
  .step-label { display: none; }
  .step-dot   { width: 28px; height: 28px; font-size: 11px; }
}

/* ── BMI CARD ────────────────────────────────────────────────── */
.bmi-card {
  background: var(--bg-raised);
  border-radius: var(--r-md);
  padding: var(--s-5);
  border: 2px solid var(--border);
  transition: var(--ease-smooth);
}
.bmi-value {
  font-size: var(--fs-3xl);
  font-family: var(--font-display);
  font-weight: var(--fw-black);
  line-height: 1;
  margin-bottom: var(--s-1);
}
.bmi-gauge-track {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
  margin: var(--s-3) 0;
}
.bmi-gauge-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.bmi-category {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
}
.bmi-message {
  font-size: var(--fs-sm);
  color: var(--t-secondary);
  margin-top: var(--s-1);
}

/* ── TOOLTIPS ────────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--c-navy);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: var(--ease-fast);
  z-index: var(--z-top);
}
[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
