/* ============================================
   FAM FITNESS — Body Measurement Tracker
   Design System & Styles
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Brand Colors (from logo) */
  --brand-red: #C41E3A;
  --brand-red-dark: #9B1A2F;
  --brand-red-glow: rgba(196, 30, 58, 0.35);
  --brand-red-light: rgba(196, 30, 58, 0.12);

  --brand-gray: #4A4A4A;
  --brand-gray-dark: #3A3A3A;
  --brand-gray-light: #5A5A5A;

  /* Surfaces */
  --bg-primary: #0A0A0A;
  --bg-secondary: #111111;
  --bg-card: #161616;
  --bg-card-hover: #1A1A1A;
  --bg-input: #1C1C1C;
  --bg-input-focus: #222222;

  /* Borders */
  --border-default: #2A2A2A;
  --border-hover: #3A3A3A;
  --border-focus: var(--brand-red);

  /* Text */
  --text-primary: #F5F5F5;
  --text-secondary: #A0A0A0;
  --text-muted: #666666;
  --text-placeholder: #555555;

  /* Status */
  --success: #22C55E;
  --error: #EF4444;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-input: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 40px var(--brand-red-glow);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --font-display: 'Oswald', sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- Background Particles ---------- */
.bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  background: var(--brand-red);
  opacity: 0;
  animation: floatParticle 15s infinite ease-in-out;
}

@keyframes floatParticle {
  0% { opacity: 0; transform: translateY(100vh) scale(0); }
  10% { opacity: 0.15; }
  50% { opacity: 0.08; }
  90% { opacity: 0.12; }
  100% { opacity: 0; transform: translateY(-10vh) scale(1); }
}

/* ---------- Container ---------- */
.container {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
}

/* ---------- Header ---------- */
.form-header {
  text-align: center;
  padding: var(--space-2xl) 0 var(--space-xl);
}

.logo-wrapper {
  display: inline-block;
  position: relative;
  margin-bottom: var(--space-lg);
}

.logo {
  width: 140px;
  height: 140px;
  object-fit: contain;
  border-radius: var(--radius-lg);
  filter: drop-shadow(0 0 30px var(--brand-red-glow));
  transition: var(--transition-normal);
}

.logo:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 0 50px var(--brand-red-glow));
}

.header-text h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.subtitle {
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.header-line {
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand-red), transparent);
  margin: var(--space-lg) auto 0;
  border-radius: 2px;
}

/* ---------- Form Sections ---------- */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-card);
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.form-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--brand-red), var(--brand-red-dark));
  border-radius: 2px 0 0 2px;
}

.form-section:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card), 0 0 60px rgba(196, 30, 58, 0.06);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.section-number {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand-red);
  line-height: 1;
  min-width: 48px;
  opacity: 0.6;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.section-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ---------- Fields Grid ---------- */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-lg);
}

.fields-grid--two {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* ---------- Field Group ---------- */
.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.field-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.required {
  color: var(--brand-red);
  font-weight: 700;
}

.unit {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
}

/* ---------- Input Wrapper ---------- */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: var(--transition-fast);
  z-index: 1;
  pointer-events: none;
}

.heart-icon {
  color: var(--brand-red);
  opacity: 0.6;
}

.heart-icon.pulse {
  animation: heartPulse 1.2s ease-in-out infinite;
}

@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

input,
select {
  width: 100%;
  padding: 14px 16px 14px 46px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 400;
  transition: var(--transition-fast);
  outline: none;
  box-shadow: var(--shadow-input);
}

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

input:hover,
select:hover {
  border-color: var(--border-hover);
  background: var(--bg-input-focus);
}

input:focus,
select:focus {
  border-color: var(--brand-red);
  background: var(--bg-input-focus);
  box-shadow: var(--shadow-input), 0 0 0 3px var(--brand-red-light);
}

input:focus ~ .field-icon,
.input-wrapper:focus-within .field-icon {
  color: var(--brand-red);
}

/* Select arrow */
.select-wrapper select {
  appearance: none;
  cursor: pointer;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 16px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px);
  pointer-events: none;
  transition: var(--transition-fast);
}

.select-wrapper:focus-within::after {
  border-color: var(--brand-red);
}

select option {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px;
}

/* Error state */
input.error,
select.error {
  border-color: var(--error);
  box-shadow: var(--shadow-input), 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.field-error {
  font-size: 0.75rem;
  color: var(--error);
  min-height: 0;
  opacity: 0;
  transition: var(--transition-fast);
}

.field-error.visible {
  opacity: 1;
  min-height: 18px;
}

/* ---------- Number input arrows hide on focus ---------- */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.3;
}

input[type="number"]:hover::-webkit-inner-spin-button,
input[type="number"]:hover::-webkit-outer-spin-button {
  opacity: 1;
}

/* ---------- Form Actions ---------- */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px 32px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 100%);
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
  color: #fff;
  box-shadow: 0 4px 20px var(--brand-red-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--brand-red-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border-default);
}

.btn-outline:hover {
  border-color: var(--brand-red);
  color: var(--brand-red);
  background: var(--brand-red-light);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top: 2px solid #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Success Overlay ---------- */
.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-slow);
}

.success-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.success-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-glow);
  transform: scale(0.9) translateY(20px);
  transition: var(--transition-slow);
}

.success-overlay.active .success-modal {
  transform: scale(1) translateY(0);
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
}

.success-icon svg {
  width: 100%;
  height: 100%;
}

.success-icon circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: circleAnim 0.6s 0.3s ease forwards;
}

.success-icon path {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: checkAnim 0.4s 0.8s ease forwards;
}

@keyframes circleAnim {
  to { stroke-dashoffset: 0; }
}

@keyframes checkAnim {
  to { stroke-dashoffset: 0; }
}

.success-modal h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.success-modal p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: var(--space-xl);
}

.success-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Footer ---------- */
.form-footer {
  text-align: center;
  padding: var(--space-xl) 0 var(--space-2xl);
}

.footer-line {
  width: 60px;
  height: 2px;
  background: var(--border-default);
  margin: 0 auto var(--space-lg);
}

.form-footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.footer-sub {
  font-size: 0.72rem !important;
  margin-top: var(--space-xs);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .container {
    padding: var(--space-md) var(--space-sm);
  }

  .form-section {
    padding: var(--space-lg) var(--space-md);
  }

  .fields-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .fields-grid--two {
    grid-template-columns: 1fr;
  }

  .logo {
    width: 110px;
    height: 110px;
  }

  .header-text h1 {
    font-size: 1.5rem;
    letter-spacing: 2px;
  }

  .section-number {
    font-size: 1.5rem;
    min-width: 36px;
  }

  .section-title {
    font-size: 1.1rem;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .btn {
    width: 100%;
    padding: 16px;
  }

  .success-modal {
    padding: var(--space-xl) var(--space-md);
  }

  .success-actions {
    flex-direction: column;
  }

  .success-actions .btn {
    width: 100%;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .fields-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Entrance Animations ---------- */
.form-section {
  animation: fadeSlideUp 0.6s ease both;
}

.form-section[data-section="1"] { animation-delay: 0.1s; }
.form-section[data-section="2"] { animation-delay: 0.2s; }
.form-section[data-section="3"] { animation-delay: 0.3s; }
.form-section[data-section="4"] { animation-delay: 0.4s; }

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-header {
  animation: fadeIn 0.8s ease both;
}

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

/* ---------- Focus-visible for accessibility ---------- */
:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: 2px;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--brand-gray);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brand-red);
}
