/* ============================================
   SK Construct — Design System
   Premium, minimal, mobile-first
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Color — Neutral */
  --color-white: #FFFFFF;
  --color-bg: #F9F9F7;
  --color-bg-alt: #F1F0EC;
  --color-surface: #FFFFFF;
  --color-surface-hover: #FAFAF8;
  --color-border: #E5E3DE;
  --color-border-focus: #C8C5BD;
  --color-text-primary: #1A1A1A;
  --color-text-secondary: #5C5C5C;
  --color-text-tertiary: #8A8A8A;
  --color-text-inverse: #FFFFFF;

  /* Color — Accent (warm amber-gold — construction brand) */
  --color-accent: #C47A1A;
  --color-accent-hover: #A86510;
  --color-accent-active: #8F560E;
  --color-accent-light: #FDF5E9;
  --color-accent-muted: #E8C893;

  /* Color — Semantic */
  --color-success: #2D8A4E;
  --color-success-bg: #EDFBF2;
  --color-error: #C0392B;
  --color-error-bg: #FDF0EE;
  --color-warning: #D4880C;
  --color-warning-bg: #FFF9EC;
  --color-info: #2874A6;
  --color-info-bg: #EBF5FB;

  /* Spacing scale (4px base) */
  --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;
  --sp-20: 80px;

  /* Typography */
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;

  --fs-h1: clamp(1.75rem, 4vw, 2.25rem);
  --fs-h2: clamp(1.375rem, 3vw, 1.75rem);
  --fs-h3: clamp(1.125rem, 2.5vw, 1.375rem);
  --fs-h4: 1.125rem;
  --fs-body: 1rem;
  --fs-body-sm: 0.9375rem;
  --fs-caption: 0.8125rem;
  --fs-tiny: 0.75rem;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.2;
  --lh-normal: 1.5;
  --lh-relaxed: 1.65;

  --ls-tight: -0.02em;
  --ls-normal: 0;
  --ls-wide: 0.02em;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.10);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
  --shadow-focus: 0 0 0 3px rgba(196, 122, 26, 0.20);
  --shadow-error-focus: 0 0 0 3px rgba(192, 57, 43, 0.18);

  /* Transitions */
  --ease-default: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 220ms;
  --duration-slow: 350ms;

  /* Layout */
  --container-sm: 480px;
  --container-md: 640px;
  --container-lg: 960px;
  --container-xl: 1200px;
  --header-height: 64px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  min-height: 100dvh;
}

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

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-default);
}

a:hover {
  color: var(--color-accent-hover);
}

/* --- Typography --- */
h1, .h1 { font-size: var(--fs-h1); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: var(--ls-tight); }
h2, .h2 { font-size: var(--fs-h2); font-weight: var(--fw-semibold); line-height: var(--lh-tight); letter-spacing: var(--ls-tight); }
h3, .h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
h4, .h4 { font-size: var(--fs-h4); font-weight: var(--fw-medium); line-height: var(--lh-normal); }

.text-secondary { color: var(--color-text-secondary); }
.text-tertiary  { color: var(--color-text-tertiary); }
.text-accent    { color: var(--color-accent); }
.text-error     { color: var(--color-error); }
.text-success   { color: var(--color-success); }
.text-center    { text-align: center; }
.text-sm        { font-size: var(--fs-body-sm); }
.text-caption   { font-size: var(--fs-caption); }
.text-tiny      { font-size: var(--fs-tiny); }
.fw-medium      { font-weight: var(--fw-medium); }
.fw-semibold    { font-weight: var(--fw-semibold); }

/* --- Layout Utilities --- */
.container {
  width: 100%;
  max-width: var(--container-lg);
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

.container-sm { max-width: var(--container-sm); }
.container-md { max-width: var(--container-md); }

.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.items-center { align-items: 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); }

/* --- Card --- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-6);
}

.card-elevated {
  box-shadow: var(--shadow-md);
}

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

.form-label {
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  color: var(--color-text-secondary);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

.form-input {
  width: 100%;
  height: 52px;
  padding: 0 var(--sp-4);
  font-family: var(--font-family);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default);
  appearance: none;
  -webkit-appearance: none;
}

.form-input:hover {
  border-color: var(--color-border-focus);
}

.form-input:focus {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
}

.form-input.error {
  border-color: var(--color-error);
  box-shadow: var(--shadow-error-focus);
}

.form-input::placeholder {
  color: var(--color-text-tertiary);
  font-weight: var(--fw-regular);
}

.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--color-bg-alt);
}

textarea.form-input {
  height: auto;
  min-height: 100px;
  padding: var(--sp-3) var(--sp-4);
  resize: vertical;
  line-height: var(--lh-relaxed);
}

select.form-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235C5C5C' viewBox='0 0 16 16'%3E%3Cpath d='M4.47 5.97a.75.75 0 0 1 1.06 0L8 8.44l2.47-2.47a.75.75 0 1 1 1.06 1.06l-3 3a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  padding-right: var(--sp-10);
}

.form-hint {
  font-size: var(--fs-caption);
  color: var(--color-text-tertiary);
}

.form-error {
  font-size: var(--fs-caption);
  color: var(--color-error);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

/* Phone input with country code */
.phone-input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.phone-prefix {
  display: flex;
  align-items: center;
  padding: 0 var(--sp-3);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  color: var(--color-text-secondary);
  background: var(--color-bg-alt);
  border: 1.5px solid var(--color-border);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  user-select: none;
}

.phone-input-group .form-input {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  letter-spacing: 0.08em;
}

/* --- OTP Input Boxes --- */
.otp-container {
  display: flex;
  justify-content: center;
  gap: var(--sp-2);
}

.otp-box {
  width: 48px;
  height: 56px;
  text-align: center;
  font-family: var(--font-family);
  font-size: 1.375rem;
  font-weight: var(--fw-bold);
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  caret-color: var(--color-accent);
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              transform var(--duration-fast) var(--ease-spring);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.otp-box::-webkit-inner-spin-button,
.otp-box::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.otp-box:hover {
  border-color: var(--color-border-focus);
}

.otp-box:focus {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
  transform: scale(1.05);
}

.otp-box.filled {
  border-color: var(--color-accent-muted);
  background: var(--color-accent-light);
}

.otp-box.error {
  border-color: var(--color-error);
  box-shadow: var(--shadow-error-focus);
  animation: shake 0.4s ease;
}

@media (min-width: 400px) {
  .otp-box {
    width: 52px;
    height: 60px;
    font-size: 1.5rem;
  }
  .otp-container {
    gap: var(--sp-3);
  }
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 52px;
  padding: 0 var(--sp-8);
  font-family: var(--font-family);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color var(--duration-normal) var(--ease-default),
              color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              transform var(--duration-fast) var(--ease-spring),
              opacity var(--duration-normal) var(--ease-default);
  position: relative;
  overflow: hidden;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Primary */
.btn-primary {
  color: var(--color-text-inverse);
  background: var(--color-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
  background: var(--color-accent-active);
}

/* Ghost / Secondary */
.btn-ghost {
  color: var(--color-accent);
  background: transparent;
  border: 1.5px solid var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-accent-light);
  border-color: var(--color-accent-muted);
}

/* Subtle / text-like */
.btn-subtle {
  color: var(--color-text-secondary);
  background: transparent;
  height: auto;
  padding: var(--sp-2) var(--sp-3);
}

.btn-subtle:hover:not(:disabled) {
  color: var(--color-accent);
  background: var(--color-accent-light);
}

/* Full width */
.btn-block {
  width: 100%;
}

/* Disabled */
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* Loading */
.btn.loading {
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-ghost.loading::after,
.btn-subtle.loading::after {
  border-color: rgba(196, 122, 26, 0.2);
  border-top-color: var(--color-accent);
}

/* Small button */
.btn-sm {
  height: 40px;
  padding: 0 var(--sp-4);
  font-size: var(--fs-body-sm);
  border-radius: var(--radius-sm);
}

/* --- Inline Alert / Message --- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-normal);
  animation: fadeSlideIn var(--duration-slow) var(--ease-default);
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.alert-info {
  background: var(--color-info-bg);
  color: var(--color-info);
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-tiny);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.badge-accent {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--sp-6) 0;
}

/* --- Step Sections (animated) --- */
.step-section {
  display: none;
  animation: fadeSlideIn var(--duration-slow) var(--ease-default);
}

.step-section.active {
  display: block;
}

/* --- Loader / Spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* --- Animations --- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
}

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

/* --- Utility --- */
.hidden   { display: none !important; }
.sr-only  {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.p-4  { padding: var(--sp-4); }
.p-6  { padding: var(--sp-6); }

/* --- Responsive --- */
@media (max-width: 480px) {
  :root {
    --sp-6: 20px;
    --sp-8: 28px;
  }

  .card {
    border-radius: var(--radius-md);
    padding: var(--sp-5);
  }

  .btn {
    height: 48px;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--sp-8);
  }
}
