/* ── Pickup Scheduler ─────────────────────────────────────────────
 * Unified date + time selector for order pickup scheduling.
 * Mobile-first, responsive, accessible.
 * Depends on: main.css design tokens (--primary, --border, --text, etc.)
 *
 * v2 — Minimalist & Professional refresh:
 *   • Softer container (shadow vs. hard border)
 *   • Circular nav arrows, generous spacing
 *   • Emoji + CSS dot hybrid indicators
 *   • Stagger-ready slot grid
 *   • Premium summary bar animation
 * ──────────────────────────────────────────────────────────────── */

/* ── Container ── */
.pickup-scheduler {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

/* ── Section label ── */
.pickup-section-label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text, #0f172a);
  letter-spacing: 0.01em;
  margin-bottom: 2px;
}

/* ────────────────────────────── CALENDAR ────────────────────────────── */

.pickup-calendar {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.02);
  user-select: none;
}

/* Month Navigation */
.pickup-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pickup-cal-nav__title {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text, #0f172a);
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.pickup-cal-nav__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  background: #fff;
  color: var(--text, #374151);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 0;
  font-family: inherit;
  line-height: 1;
}

.pickup-cal-nav__btn:hover:not([disabled]) {
  border-color: var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.05);
  color: var(--primary, #2563eb);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.pickup-cal-nav__btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.pickup-cal-nav__btn:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* Day-of-Week Headers */
.pickup-cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 6px;
}

.pickup-cal-header__day {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 0;
}

/* Day Grid */
.pickup-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

/* Individual Day Cell */
.pickup-day {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text, #0f172a);
  font-size: 0.84rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  min-width: 0;
  min-height: 40px;
  line-height: 1;
  touch-action: manipulation; /* Prevent double-tap zoom on mobile */
  -webkit-tap-highlight-color: transparent;
}

/* Hover only on pointer devices — prevents "gray first tap" on mobile */
@media (hover: hover) and (pointer: fine) {
  .pickup-day:hover:not([disabled]):not(.pickup-day--selected) {
    background: rgba(37, 99, 235, 0.06);
    color: var(--primary, #2563eb);
    transform: scale(1.02);
  }
}

/* Day: empty cell (padding for calendar alignment) */
.pickup-day--empty {
  cursor: default;
  pointer-events: none;
}

/* Day: Today — subtle dot indicator (non-competing with selected) */
.pickup-day--today:not(.pickup-day--selected) {
  font-weight: 700;
  color: var(--primary, #2563eb);
  position: relative;
}

.pickup-day--today:not(.pickup-day--selected)::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary, #2563eb);
}

/* Day: Selected — premium glow, always wins over today */
.pickup-day--selected {
  background: var(--primary, #2563eb);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
  transform: scale(1.02);
  border: none;
}

/* Remove today dot when this cell is also selected */
.pickup-day--selected.pickup-day--today::after {
  display: none;
}

/* Day: Disabled (past, out-of-range) */
.pickup-day:disabled,
.pickup-day--disabled {
  color: var(--muted, #9ca3af);
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Day: Closed (schedule) — strikethrough + dot indicator */
.pickup-day--closed {
  color: var(--muted, #9ca3af);
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  text-decoration: line-through;
}

.pickup-day--closed::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted, #94a3b8);
}

/* Day: Holiday — strikethrough + colored dot */
.pickup-day--holiday {
  color: #b91c1c;
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  text-decoration: line-through;
}

.pickup-day--holiday::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ef4444;
}

/* Focus visible for day cells */
.pickup-day:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  z-index: 1;
}

/* ────────────────────────────── SLOT GRID ────────────────────────────── */

.pickup-slots {
  min-height: 0;
}

.pickup-slots-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text, #0f172a);
  margin-bottom: 8px;
}

/* Styled count dot beside the label */
.pickup-slots-label::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary, #2563eb);
  flex-shrink: 0;
}

/* Horizontal scroll wrapper (rendered by JS) */
.pickup-slots-scroller {
  position: relative;
}

.pickup-slots-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

/* Fade-edge scroll indicators (mobile only, rendered by JS) */
.pickup-slots-fade {
  display: none;
}

/* Individual Slot Button */
.pickup-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--border, #e2e8f0);
  background: #fff;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.18s ease;
  line-height: 1.3;
  min-height: 54px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Stagger-ready animation class (applied via JS) */
.pickup-slot[data-stagger] {
  opacity: 0;
  transform: translateY(6px);
  animation: pickupSlotIn 0.25s ease forwards;
}

@keyframes pickupSlotIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pickup-slot:hover:not([disabled]):not(.pickup-slot--selected) {
  border-color: var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.03);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

/* On touch devices, also wrap hover in pointer query */
@media (hover: none) {
  .pickup-slot:hover:not([disabled]):not(.pickup-slot--selected) {
    border-color: var(--border, #e2e8f0);
    background: #fff;
    transform: none;
    box-shadow: none;
  }
}

/* Slot: Selected — clean, no !important */
.pickup-slot--selected {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.25);
  transform: scale(1.01);
}

.pickup-slot--selected .pickup-slot__remaining {
  opacity: 0.9;
  color: #fff;
}

.pickup-slot--selected .pickup-slot__check {
  display: inline;
}

/* Slot: Limited — emoji kept + amber dot indicator */
.pickup-slot--limited {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.03);
}

.pickup-slot--limited::before {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 4px rgba(245, 158, 11, 0.4);
}

.pickup-slot--limited .pickup-slot__remaining {
  color: #b45309;
}

/* Slot: Disabled (full or past) */
.pickup-slot:disabled,
.pickup-slot[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  background: #fafafa;
  border-color: #e5e7eb;
}

/* Slot: Past — subtle diagonal stripe */
.pickup-slot--past {
  background: repeating-linear-gradient(
    -45deg,
    #fafafa,
    #fafafa 4px,
    #f0f0f0 4px,
    #f0f0f0 8px
  );
}

.pickup-slot__time {
  font-weight: 700;
  font-size: 0.9rem;
}

.pickup-slot__remaining {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 400;
  opacity: 0.65;
  margin-top: 2px;
}

.pickup-slot__check {
  display: none;
  margin-left: 4px;
}

/* Slot: Focus visible */
.pickup-slot:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  z-index: 1;
}

/* Slot: Skeleton (loading placeholder) */
.pickup-slot-skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: pickup-shimmer 1.4s ease-in-out infinite;
  border-radius: 10px;
  min-height: 54px;
}

@keyframes pickup-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Slot: No slots message */
.pickup-slots-empty {
  text-align: center;
  color: var(--muted, #64748b);
  font-size: 0.85rem;
  padding: 20px 8px;
  line-height: 1.5;
}

.pickup-slots-empty a {
  color: var(--primary, #2563eb);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.15s ease;
}

.pickup-slots-empty a:hover {
  opacity: 0.75;
}

/* ────────────────────────────── SUMMARY BAR ────────────────────────── */

.pickup-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-left: 3px solid var(--primary, #2563eb);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text, #0f172a);
  animation: pickup-summary-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* SVG icon */
.pickup-summary__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(37, 99, 235, 0.07);
  color: var(--primary, #2563eb);
}

.pickup-summary__icon svg {
  width: 15px;
  height: 15px;
}

/* Single-line text: "Lun 27 abr · 20:30" */
.pickup-summary__text {
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--text, #0f172a);
  line-height: 1.3;
  white-space: nowrap;
}

.pickup-summary__text .pickup-summary__sep {
  color: var(--muted, #94a3b8);
  margin: 0 3px;
  font-weight: 400;
}

/* Change button */
.pickup-summary__change {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--primary, #2563eb);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.pickup-summary__change:hover {
  background: rgba(37, 99, 235, 0.08);
}

.pickup-summary__change:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}

@keyframes pickup-summary-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Summary: Mobile ≤ 540px ── */
@media (max-width: 540px) {
  .pickup-summary {
    padding: 9px 12px;
    gap: 8px;
  }

  .pickup-summary__icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
  }

  .pickup-summary__icon svg {
    width: 14px;
    height: 14px;
  }

  .pickup-summary__text {
    font-size: 0.82rem;
  }
}

/* ── Summary: Desktop ≥ 1024px ── */
@media (min-width: 1024px) {
  .pickup-summary__text {
    font-size: 0.86rem;
  }
}

/* ────────────────────────────── ERROR DISPLAY ────────────────────────── */

.pickup-error {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.4;
  font-weight: 500;
}

/* User-fixable: amber */
.pickup-error--user {
  background: rgba(245, 158, 11, 0.06);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.15);
}

/* User-fixable: dot indicator */
.pickup-error--user::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  flex-shrink: 0;
}

/* System-fixable: red with retry */
.pickup-error--system {
  background: rgba(239, 68, 68, 0.05);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.12);
}

.pickup-error--system::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
}

.pickup-error__retry {
  display: inline-block;
  margin-left: 8px;
  border: none;
  background: transparent;
  color: var(--primary, #2563eb);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  text-decoration: underline;
}

/* ────────────────────────────── RESPONSIVE ────────────────────────── */

/* Mobile ≤ 540px: horizontal swipeable slot carousel */
@media (max-width: 540px) {
  .pickup-day {
    min-height: 38px;
    font-size: 0.8rem;
  }

  /* Convert grid → horizontal scroll */
  .pickup-slots-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 6px;
    /* Hide scrollbar for clean look */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .pickup-slots-grid::-webkit-scrollbar {
    display: none;
  }

  .pickup-slot {
    flex: 0 0 auto;
    width: 100px;
    min-height: 64px;
    padding: 10px 8px;
    scroll-snap-align: start;
    border-radius: 12px;
  }

  /* Skeleton: match horizontal layout */
  .pickup-slot-skeleton {
    flex: 0 0 auto;
    width: 100px;
    min-height: 64px;
  }

  /* Fade-edge indicators */
  .pickup-slots-fade {
    display: block;
    position: absolute;
    top: 0;
    bottom: 6px;
    width: 28px;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.2s ease;
  }
  .pickup-slots-fade--left {
    left: 0;
    background: linear-gradient(to right, #fff 30%, transparent);
  }
  .pickup-slots-fade--right {
    right: 0;
    background: linear-gradient(to left, #fff 30%, transparent);
  }
  .pickup-slots-fade.is-hidden {
    opacity: 0;
  }

  .pickup-calendar {
    padding: 10px;
    border-radius: 12px;
  }
}

/* Tablet 541px – 1023px: 3-col slots */
@media (min-width: 541px) and (max-width: 1023px) {
  .pickup-day {
    min-height: 42px;
    font-size: 0.84rem;
  }
  .pickup-slots-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop ≥ 1024px: 4-col slots */
@media (min-width: 1024px) {
  .pickup-day {
    min-height: 44px;
  }
  .pickup-slots-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pickup-slot-skeleton {
    animation: none;
  }
  .pickup-summary {
    animation: none;
  }
  .pickup-slot[data-stagger] {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .pickup-day,
  .pickup-slot,
  .pickup-cal-nav__btn {
    transition: none;
  }
}
