/* ==================== BASE ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

html { scroll-behavior: smooth; }

body {
  -webkit-font-smoothing: antialiased;
}

.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* ==================== SCREENS ==================== */
.screen {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.active {
  display: flex;
  opacity: 1;
}

/* ==================== BUTTONS ==================== */
.btn-primary {
  background-color: #1D9E75;
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-appearance: none;
}

.btn-primary:hover { background-color: #23b888; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

/* ==================== FORM INPUTS ==================== */
.form-input {
  background-color: #1A1A1A;
  border: 1px solid #333333;
  border-radius: 12px;
  padding: 12px 16px;
  color: #FFFFFF;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus { outline: none; border-color: #1D9E75; }
.form-input::placeholder { color: #666666; }

/* ==================== OCCASION CARDS ==================== */
.occasion-card {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.occasion-card:active { transform: scale(0.96); }

.occasion-card.selected .occasion-img {
  outline: 3px solid #1D9E75;
  outline-offset: -3px;
}

/* ==================== GALLERY ITEMS ==================== */
.gallery-item {
  position: relative;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 3/4;
  background-color: #1A1A1A;
  transition: transform 0.15s ease;
}

.gallery-item:active { transform: scale(0.97); }

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item .check-overlay {
  position: absolute;
  inset: 0;
  background: rgba(29, 158, 117, 0.3);
  display: none;
  align-items: center;
  justify-content: center;
}

.gallery-item.selected {
  outline: 3px solid #1D9E75;
  outline-offset: -3px;
}

.gallery-item.selected .check-overlay { display: flex; }

/* Popularity badge */
.gallery-item .popularity-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  color: #AAAAAA;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 8px;
  z-index: 2;
}

/* ==================== BEFORE/AFTER SLIDER ==================== */
.ba-slider {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  touch-action: none;
  cursor: ew-resize;
}

.ba-slider .ba-before,
.ba-slider .ba-after {
  position: absolute;
  inset: 0;
}

.ba-slider .ba-before img,
.ba-slider .ba-after img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ba-slider .ba-before {
  clip-path: inset(0 50% 0 0);
  z-index: 2;
}

.ba-slider .ba-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: #1D9E75;
  z-index: 3;
  transform: translateX(-50%);
}

.ba-slider .ba-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: #1D9E75;
  border: 3px solid white;
  border-radius: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.ba-slider .ba-label {
  position: absolute;
  bottom: 12px;
  z-index: 5;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

.ba-slider .ba-label-before { left: 12px; background: rgba(0,0,0,0.6); }
.ba-slider .ba-label-after { right: 12px; background: rgba(29,158,117,0.8); }

/* ==================== SOCIAL PROOF NOTIFICATION ==================== */
.social-proof {
  position: fixed;
  bottom: 80px;
  left: 12px;
  right: 12px;
  max-width: 360px;
  background: #1A1A1A;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 12px 14px;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  animation: slideUp 0.4s ease-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.social-proof.hiding {
  opacity: 0;
  transform: translateY(20px);
}

.social-proof-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1D9E75, #23b888);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

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

/* ==================== MOODBOARD ==================== */
.moodboard-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 0;
}

.moodboard-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #1D9E75;
  animation: popIn 0.3s ease-out;
}

.moodboard-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==================== COUNTDOWN TIMER ==================== */
.countdown {
  display: inline-flex;
  gap: 4px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
}

.countdown-unit {
  background: #1A1A1A;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 36px;
  text-align: center;
  font-size: 14px;
}

.countdown-label {
  font-size: 8px;
  color: #AAAAAA;
  display: block;
  margin-top: 1px;
}

/* ==================== EXIT INTENT MODAL ==================== */
.exit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.exit-modal {
  background: #1A1A1A;
  border: 1px solid #333;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  animation: popIn 0.4s ease-out;
}

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

/* ==================== STAGED LOADING ==================== */
.stage-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  transition: opacity 0.3s ease;
}

.stage-item.done { color: #1D9E75; }
.stage-item.active { color: #FFFFFF; }
.stage-item.pending { color: #666666; }

.stage-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
}

.stage-item.done .stage-dot { background: #1D9E75; }
.stage-item.active .stage-dot { background: #333; border: 2px solid #1D9E75; animation: pulse 1s infinite; }
.stage-item.pending .stage-dot { background: #333; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(29,158,117,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(29,158,117,0); }
}

/* ==================== PROGRESS MESSAGE ==================== */
#progress-message {
  position: fixed;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 39;
  font-size: 10px;
  color: #AAAAAA;
  background: #111111ee;
  padding: 2px 12px;
  border-radius: 10px;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

/* ==================== TOGGLE SWITCH ==================== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #333333;
  border-radius: 26px;
  transition: 0.3s;
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider { background-color: #1D9E75; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(22px); }

/* ==================== SELFIE PREVIEWS ==================== */
.selfie-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background-color: #1A1A1A;
}

.selfie-preview img { width: 100%; height: 100%; object-fit: cover; }

.selfie-preview .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
}

/* ==================== CHECK ANIMATION ==================== */
.check-animation { animation: popIn 0.5s ease-out; }
.check-icon { animation: drawCheck 0.5s ease-out 0.3s both; }

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes drawCheck {
  0% { stroke-dasharray: 40; stroke-dashoffset: 40; }
  100% { stroke-dashoffset: 0; }
}

/* ==================== SPINNER ==================== */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #333333;
  border-top-color: #1D9E75;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

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

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid #333;
  border-top-color: #1D9E75;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

/* ==================== SAFE AREA ==================== */
@supports (padding: env(safe-area-inset-bottom)) {
  .fixed.bottom-0 {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 768px) {
  body {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid #333;
    border-right: 1px solid #333;
    min-height: 100vh;
  }

  .fixed {
    max-width: 480px;
    left: 50% !important;
    transform: translateX(-50%);
  }

  .social-proof { left: auto; right: 16px; }
}
