/* ==========================================================================
   Let’s Hair (렛츠헤어) Design System v2.0
   Unified visual language, accessible interaction tokens, and custom UI primitives.
   Strictly avoids unstyled native browser UI in favor of branded custom elements.
   ========================================================================== */

:root {
  /* Brand Colors */
  --lh-pink: #f35381;
  --lh-pink-hover: #e34170;
  --lh-pink-active: #cc2f5e;
  --lh-pink-deep: #c92557;       /* WCAG AA (>= 4.5:1 on white/light surfaces) */
  --lh-pink-soft: #fff0f5;
  --lh-pink-subtle: #fff8fa;
  --lh-pink-glow: rgba(243, 83, 129, 0.28);

  /* Semantic Ink & Neutrals (Strict WCAG AA Conformance) */
  --lh-ink: #1e1924;             /* 14.8:1 contrast on white */
  --lh-muted-strong: #3f3642;    /* 8.5:1 contrast on white */
  --lh-muted: #5a505e;           /* 5.5:1 contrast on white (Passes WCAG AA for body text) */
  --lh-muted-light: #7a707e;     /* 3.8:1 contrast (large text or decorative only) */

  /* Surface & Background */
  --lh-bg: #fdfafc;
  --lh-surface: #ffffff;
  --lh-surface-soft: #fcf6f9;
  --lh-surface-card: rgba(255, 255, 255, 0.94);
  --lh-line: #e8dce4;
  --lh-line-subtle: #f2e9ef;

  /* States & Highlights */
  --lh-danger: #c92557;          /* High-contrast danger / holiday */
  --lh-danger-soft: #ffebee;
  --lh-success: #198754;
  --lh-success-soft: #eaf6ed;
  --lh-sunday: #d32f2f;          /* 4.8:1 contrast on white */
  --lh-saturday: #1565c0;        /* 5.1:1 contrast on white */
  --lh-focus-ring: #0062d2;      /* Distinct high-contrast blue for focus-visible */

  /* Geometry & Radius */
  --lh-radius-xs: 6px;
  --lh-radius-sm: 10px;
  --lh-radius-md: 16px;
  --lh-radius-lg: 24px;
  --lh-radius-xl: 32px;
  --lh-radius-pill: 9999px;

  /* Spatial Scale (4px base) */
  --lh-space-1: 4px;
  --lh-space-2: 8px;
  --lh-space-3: 12px;
  --lh-space-4: 16px;
  --lh-space-5: 20px;
  --lh-space-6: 24px;
  --lh-space-7: 32px;
  --lh-space-8: 40px;

  /* Touch Target Standard */
  --lh-touch-target: 44px;

  /* Shadows & Elevation */
  --lh-shadow-sm: 0 2px 6px rgba(30, 25, 36, 0.05);
  --lh-shadow-md: 0 6px 18px rgba(30, 25, 36, 0.09);
  --lh-shadow-lg: 0 14px 34px rgba(30, 25, 36, 0.14);
  --lh-shadow-float: 0 16px 40px rgba(38, 16, 32, 0.22);
  --lh-shadow-pink: 0 6px 20px rgba(243, 83, 129, 0.35);

  /* Motion & Physics Transitions */
  --lh-ease-spring: cubic-bezier(0.18, 0.89, 0.32, 1.28);
  --lh-ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
  --lh-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --lh-duration-fast: 160ms;
  --lh-duration-base: 240ms;
  --lh-duration-slide: 280ms;

  /* Safe Area Insets (with robust fallbacks) */
  --lh-safe-top: env(safe-area-inset-top, 0px);
  --lh-safe-bottom: env(safe-area-inset-bottom, 0px);
  --lh-safe-left: env(safe-area-inset-left, 0px);
  --lh-safe-right: env(safe-area-inset-right, 0px);
}

/* Base Normalization & Typography */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

body {
  color: var(--lh-ink);
  background-color: var(--lh-bg);
  line-height: 1.55;
  font-family: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  letter-spacing: -0.015em;
  margin: 0;
  padding: 0;
  padding-bottom: var(--lh-safe-bottom);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Accessible Focus Visible Ring */
:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 3px solid var(--lh-focus-ring) !important;
  outline-offset: 3px !important;
}

:where(button, a, input, textarea, select, [tabindex]):focus:not(:focus-visible) {
  outline: none;
}

/* Standardized Tap Target & Reset */
button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font: inherit;
}

/* ==========================================================================
   Custom UI Primitives (No Raw System Controls)
   ========================================================================== */

/* 1. Custom Button: .lh-button */
.lh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--lh-touch-target);
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--lh-radius-md);
  background: var(--lh-pink);
  color: #ffffff;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--lh-duration-fast) ease,
              background-color var(--lh-duration-fast) ease,
              box-shadow var(--lh-duration-fast) ease,
              opacity var(--lh-duration-fast) ease;
  user-select: none;
  -webkit-user-select: none;
}

.lh-button:hover {
  background: var(--lh-pink-hover);
  box-shadow: var(--lh-shadow-pink);
  transform: translateY(-1px);
}

.lh-button:active {
  background: var(--lh-pink-active);
  transform: translateY(1px);
}

.lh-button:disabled,
.lh-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
  transform: none;
}

.lh-button--secondary {
  background: var(--lh-surface);
  color: var(--lh-ink);
  border-color: var(--lh-line);
}

.lh-button--secondary:hover {
  background: var(--lh-surface-soft);
  border-color: var(--lh-pink);
  color: var(--lh-pink-deep);
  box-shadow: var(--lh-shadow-sm);
}

.lh-button--ghost {
  background: transparent;
  color: var(--lh-muted-strong);
  border-color: transparent;
}

.lh-button--ghost:hover {
  background: var(--lh-pink-soft);
  color: var(--lh-pink-deep);
}

/* 2. Custom Input: .lh-input */
.lh-input {
  display: block;
  width: 100%;
  min-height: var(--lh-touch-target);
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--lh-line);
  border-radius: var(--lh-radius-md);
  background: #ffffff;
  color: var(--lh-ink);
  padding: 10px 14px;
  font-size: 0.9375rem;
  line-height: 1.4;
  outline: none;
  transition: border-color var(--lh-duration-fast) ease,
              box-shadow var(--lh-duration-fast) ease,
              background-color var(--lh-duration-fast) ease;
}

.lh-input::placeholder {
  color: var(--lh-muted-light);
  opacity: 0.85;
}

.lh-input:focus {
  border-color: var(--lh-pink);
  box-shadow: 0 0 0 3px var(--lh-pink-glow);
  background: #ffffff;
}

.lh-input:disabled {
  background: #f7f5f7;
  color: var(--lh-muted);
  cursor: not-allowed;
}

/* 3. Custom Segmented Tabs (Eliminates Browser Gray Buttonface) */
.lh-tabs-container {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

.container_tab .tabs {
  display: flex;
  align-items: center;
  position: relative;
  background-color: var(--lh-surface);
  box-shadow: var(--lh-shadow-md);
  border: 1px solid var(--lh-line-subtle);
  padding: 5px;
  border-radius: var(--lh-radius-pill);
  min-height: 56px;
  box-sizing: border-box;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.container_tab .tab {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--lh-muted-strong);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  border-radius: var(--lh-radius-pill);
  padding: 12px 16px;
  min-height: 44px;
  cursor: pointer;
  text-align: center;
  transition: color var(--lh-duration-fast) ease,
              background-color var(--lh-duration-fast) ease,
              box-shadow var(--lh-duration-fast) ease,
              transform var(--lh-duration-fast) ease;
  user-select: none;
  -webkit-user-select: none;
}

.container_tab .tab:hover:not(.tab_select) {
  color: var(--lh-ink);
  background-color: var(--lh-pink-soft);
}

.container_tab .tab.tab_select {
  background: var(--lh-pink);
  color: #ffffff;
  box-shadow: var(--lh-shadow-pink);
}

/* 4. Custom Switch & Holiday Chips */
.lh-chip-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.lh-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--lh-touch-target);
  padding: 8px 14px;
  border: 1.5px solid var(--lh-line);
  border-radius: var(--lh-radius-md);
  background: var(--lh-surface);
  color: var(--lh-muted-strong);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--lh-duration-fast) ease;
  user-select: none;
}

.lh-chip:hover {
  border-color: var(--lh-pink);
  color: var(--lh-pink-deep);
  background: var(--lh-pink-subtle);
}

.lh-chip.is-active,
.lh-chip[aria-pressed="true"] {
  border-color: var(--lh-pink);
  background: var(--lh-pink-soft);
  color: var(--lh-pink-deep);
  box-shadow: 0 2px 8px rgba(243, 83, 129, 0.18);
}

/* Day of week selection row (Sun, Mon, Tue, ...) */
.lh-weekday-chips {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin: 10px 0;
}

.lh-weekday-chip {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 6px 2px;
  border: 1.5px solid var(--lh-line);
  border-radius: var(--lh-radius-sm);
  background: #ffffff;
  color: var(--lh-ink);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--lh-duration-fast) ease;
}

.lh-weekday-chip:hover {
  border-color: var(--lh-pink);
  background: var(--lh-pink-subtle);
}

.lh-weekday-chip.is-closed {
  border-color: var(--lh-pink);
  background: var(--lh-pink);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(243, 83, 129, 0.32);
}

.lh-weekday-chip.is-closed .chip-sub {
  color: #ffe6ee;
}

.lh-weekday-chip .chip-sub {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--lh-muted);
  margin-top: 2px;
}

/* 5. Custom Modal & Dialog Framework */
.lh-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 12, 22, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, var(--lh-safe-top)) max(16px, var(--lh-safe-right)) max(16px, var(--lh-safe-bottom)) max(16px, var(--lh-safe-left));
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--lh-duration-base) ease;
}

.lh-modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lh-modal-card {
  position: relative;
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - var(--lh-safe-top) - var(--lh-safe-bottom) - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--lh-surface);
  border-radius: var(--lh-radius-xl);
  box-shadow: var(--lh-shadow-float);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 24px;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--lh-duration-base) var(--lh-ease-spring);
}

.lh-modal-backdrop.is-open .lh-modal-card {
  transform: translateY(0) scale(1);
}

.lh-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--lh-line-subtle);
}

.lh-modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--lh-ink);
  letter-spacing: -0.02em;
}

.lh-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--lh-surface-soft);
  color: var(--lh-muted);
  font-size: 1.4rem;
  cursor: pointer;
  transition: all var(--lh-duration-fast) ease;
}

.lh-modal-close:hover {
  background: #f0e6ec;
  color: var(--lh-ink);
}

/* 6. Calendar Physics Carousel Layer */
.calendar-carousel-viewport {
  position: relative;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.calendar-carousel-track {
  position: relative;
  width: 100%;
  will-change: transform, opacity;
  transform: translateX(0);
}

.calendar-carousel-track.is-animating {
  transition: transform var(--lh-duration-slide) var(--lh-ease-smooth),
              opacity var(--lh-duration-slide) ease;
}

.calendar-carousel-track.is-bouncing {
  transition: transform 320ms var(--lh-ease-spring),
              opacity 320ms ease;
}

/* Calendar Date Cells & States */
.calendar {
  width: 100%;
  border-spacing: 0;
  table-layout: fixed;
  text-align: center;
}

.calendar th {
  padding: 10px 0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--lh-muted);
}

.calendar th.sunday {
  color: var(--lh-sunday);
}

.calendar td {
  padding: 4px 2px;
  vertical-align: top;
  text-align: center;
}

.calendar .calendar-date {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  width: 100%;
  max-width: 52px;
  margin: 0 auto;
  padding: 4px;
  border: 1.5px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--lh-ink);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--lh-duration-fast) ease,
              border-color var(--lh-duration-fast) ease,
              color var(--lh-duration-fast) ease,
              transform var(--lh-duration-fast) ease,
              box-shadow var(--lh-duration-fast) ease;
}

.calendar .calendar-date:hover:not(:disabled) {
  background: var(--lh-pink-soft);
  color: var(--lh-pink-deep);
  transform: scale(1.05);
}

.calendar .calendar-date.sunday {
  color: var(--lh-sunday);
}

.calendar .calendar-date.today {
  border-color: var(--lh-pink);
  font-weight: 800;
}

.calendar .calendar-date.selected {
  background: var(--lh-pink) !important;
  color: #ffffff !important;
  box-shadow: var(--lh-shadow-pink);
  transform: scale(1.04);
}

.calendar .calendar-date:disabled,
.calendar .calendar-date[aria-disabled="true"] {
  cursor: not-allowed !important;
  opacity: 0.38;
  color: var(--lh-muted);
  transform: none !important;
  background: transparent !important;
}

/* Holiday Badge Pill */
.calendar-holiday-label {
  display: block;
  min-height: 18px;
  max-width: 90%;
  margin: 2px auto 0;
  padding: 1px 4px;
  border-radius: 6px;
  background: var(--lh-danger-soft);
  color: var(--lh-danger);
  font-size: 0.6875rem;
  font-weight: 800;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 7. Toast Alerts (Replaces system alerts) */
.lh-toast-region {
  position: fixed;
  z-index: 2000;
  right: max(16px, var(--lh-safe-right));
  bottom: max(18px, calc(var(--lh-safe-bottom) + 14px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.lh-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--lh-radius-md);
  background: rgba(28, 22, 34, 0.95);
  box-shadow: var(--lh-shadow-float);
  color: #ffffff;
  padding: 14px 18px;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: lh-toast-in 220ms var(--lh-ease-smooth) both;
}

.lh-toast--error {
  background: rgba(184, 24, 66, 0.96);
}

.lh-toast--success {
  background: rgba(22, 101, 62, 0.96);
}

@keyframes lh-toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Responsive Viewport Calibration (320px ~ 1920px)
   ========================================================================== */

/* Compact Mobile (320px - 479px) */
@media screen and (max-width: 479px) {
  .calendar th {
    padding: 6px 0;
    font-size: 0.8125rem;
  }
  .calendar .calendar-date {
    min-width: 38px;
    min-height: 38px;
    font-size: 0.875rem;
  }
  .calendar-holiday-label {
    font-size: 0.625rem;
    padding: 0 2px;
  }
  .lh-modal-card {
    padding: 18px 14px;
    border-radius: var(--lh-radius-lg);
  }
}

/* Wide Desktop & 1920px Support */
@media screen and (min-width: 960px) {
  .lh-tabs-container {
    max-width: 720px;
  }
  .calendar-carousel-viewport {
    max-width: 900px;
  }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
