/* ── Price Calendar Styles ──────────────────────────────────────────────── */

.price-calendar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  background: var(--bg2);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.price-calendar--loading,
.price-calendar--empty,
.price-calendar--error {
  display: block;
  text-align: center;
}

.price-calendar__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;
}

.price-calendar__message {
  font-size: 14px;
  color: var(--text2);
  padding: 24px 8px;
}

.price-calendar__retry {
  margin-top: 4px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.price-calendar__retry:hover {
  background: #1557b0;
}

/* ── Month section ─────────────────────────────────────────────────────── */

.price-calendar__month {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  contain: layout style paint;
  border-radius: 8px;
}

.price-calendar__month--pending {
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}

.price-calendar__month-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
  text-align: center;
}

/* ── Grid ──────────────────────────────────────────────────────────────── */

.price-calendar__weekdays,
.price-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.price-calendar__weekday {
  font-size: 10px;
  color: var(--text3);
  text-align: center;
  padding: 2px 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ── Day cell ──────────────────────────────────────────────────────────── */

.price-calendar__day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  min-height: 46px;
  padding: 2px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--bg);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s, border-color 0.15s;
  user-select: none;
  animation: pcalFadeIn 0.25s ease both;
}

/* Staggered fade-in per column */
.price-calendar__grid .price-calendar__day:nth-child(7n + 1) {
  animation-delay: 0ms;
}
.price-calendar__grid .price-calendar__day:nth-child(7n + 2) {
  animation-delay: 20ms;
}
.price-calendar__grid .price-calendar__day:nth-child(7n + 3) {
  animation-delay: 40ms;
}
.price-calendar__grid .price-calendar__day:nth-child(7n + 4) {
  animation-delay: 60ms;
}
.price-calendar__grid .price-calendar__day:nth-child(7n + 5) {
  animation-delay: 80ms;
}
.price-calendar__grid .price-calendar__day:nth-child(7n + 6) {
  animation-delay: 100ms;
}
.price-calendar__grid .price-calendar__day:nth-child(7n + 7) {
  animation-delay: 120ms;
}

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

.price-calendar__day:hover {
  background: var(--border);
}

.price-calendar__day:focus-visible {
  outline: none;
  border-color: #1a73e8;
}

.price-calendar__day-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.price-calendar__day-price {
  font-size: 10px;
  font-weight: 500;
  margin-top: 2px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Day states ────────────────────────────────────────────────────────── */

.price-calendar__day--empty {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
  cursor: default;
  animation: none;
}

.price-calendar__day--past {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.price-calendar__day--missing {
  opacity: 0.6;
  cursor: default;
}

.price-calendar__day--missing .price-calendar__day-price {
  color: var(--text3);
}

.price-calendar__day--cheap {
  background: #dcfce7;
  color: #166534;
}

.price-calendar__day--cheap .price-calendar__day-num,
.price-calendar__day--cheap .price-calendar__day-price {
  color: #166534;
}

.price-calendar__day--mid {
  background: #fef9c3;
  color: #854d0e;
}

.price-calendar__day--mid .price-calendar__day-num,
.price-calendar__day--mid .price-calendar__day-price {
  color: #854d0e;
}

.price-calendar__day--exp {
  background: #fee2e2;
  color: #991b1b;
}

.price-calendar__day--exp .price-calendar__day-num,
.price-calendar__day--exp .price-calendar__day-price {
  color: #991b1b;
}

.price-calendar__day--full,
.price-calendar__day--soldout {
  background: var(--border);
  color: var(--text3);
  cursor: not-allowed;
  pointer-events: none;
}

.price-calendar__day--full .price-calendar__day-num,
.price-calendar__day--soldout .price-calendar__day-num {
  color: var(--text3);
}

.price-calendar__day--selected {
  border-color: #1a73e8;
  transform: scale(1.05);
  z-index: 1;
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.25);
}

.price-calendar__day--today {
  border-color: #4caf50;
}

/* ── Decorations ───────────────────────────────────────────────────────── */

.price-calendar__star {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 9px;
  color: #eab308;
  pointer-events: none;
  line-height: 1;
}

.price-calendar__day-change {
  font-size: 7px;
  line-height: 1;
  margin-top: 1px;
  display: inline-block;
}

.price-calendar__day-change--up {
  color: #dc2626;
}

.price-calendar__day-change--down {
  color: #16a34a;
}

.price-calendar__day--selected .price-calendar__day-change {
  color: #fff;
}

.price-calendar__day-dep {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: #ff5722;
  color: #fff;
  font-size: 7px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ── Legend ────────────────────────────────────────────────────────────── */

.price-calendar__legend {
  display: flex;
  gap: 14px;
  padding: 10px 0 0;
  flex-wrap: wrap;
  justify-content: center;
}

.price-calendar__legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text3);
}

.price-calendar__legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.price-calendar__legend-dot--cheap {
  background: #dcfce7;
}

.price-calendar__legend-dot--mid {
  background: #fef9c3;
}

.price-calendar__legend-dot--exp {
  background: #fee2e2;
}

.price-calendar__legend-star {
  font-size: 9px;
  color: #eab308;
}

/* ── Skeleton ──────────────────────────────────────────────────────────── */

.price-calendar__grid--skeleton {
  gap: 2px;
}

.price-calendar__skeleton-cell {
  aspect-ratio: 1 / 1;
  min-height: 46px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--border) 0%, var(--bg) 50%, var(--border) 100%);
  background-size: 200% 100%;
  animation: pcalShimmer 1.2s ease-in-out infinite;
}

.price-calendar__skeleton-title {
  height: 16px;
  width: 60%;
  margin: 0 auto 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--border) 0%, var(--bg) 50%, var(--border) 100%);
  background-size: 200% 100%;
  animation: pcalShimmer 1.2s ease-in-out infinite;
}

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

/* ── Dark mode ─────────────────────────────────────────────────────────── */

body.dark .price-calendar__day--cheap {
  background: #14532d;
  color: #bbf7d0;
}

body.dark .price-calendar__day--cheap .price-calendar__day-num,
body.dark .price-calendar__day--cheap .price-calendar__day-price {
  color: #bbf7d0;
}

body.dark .price-calendar__day--mid {
  background: #422006;
  color: #fde68a;
}

body.dark .price-calendar__day--mid .price-calendar__day-num,
body.dark .price-calendar__day--mid .price-calendar__day-price {
  color: #fde68a;
}

body.dark .price-calendar__day--exp {
  background: #450a0a;
  color: #fecaca;
}

body.dark .price-calendar__day--exp .price-calendar__day-num,
body.dark .price-calendar__day--exp .price-calendar__day-price {
  color: #fecaca;
}

body.dark .price-calendar__day--today {
  border-color: #66bb6a;
}

body.dark .price-calendar__day-change--up {
  color: #fca5a5;
}

body.dark .price-calendar__day-change--down {
  color: #86efac;
}

/* ── Mobile nav (single month view) ────────────────────────────────────── */

.price-calendar__nav {
  display: none;
}

.price-calendar__dots {
  display: none;
}

@media (max-width: 760px) {
  .price-calendar {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 12px;
  }

  .price-calendar__months {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .price-calendar__months::-webkit-scrollbar {
    display: none;
  }

  .price-calendar__month {
    flex: 0 0 100%;
    scroll-snap-align: start;
  }

  .price-calendar__nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }

  .price-calendar__nav-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: var(--text);
    transition: background 0.15s;
  }

  .price-calendar__nav-btn:hover {
    background: var(--border);
  }

  .price-calendar__nav-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }

  .price-calendar__dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
  }

  .price-calendar__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.2s;
  }

  .price-calendar__dot--active {
    background: #1a73e8;
  }

  .price-calendar__weekdays {
    display: none;
  }

  .price-calendar__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .price-calendar__day {
    aspect-ratio: auto;
    min-height: auto;
    flex-direction: row;
    justify-content: space-between;
    padding: 10px 12px;
    gap: 8px;
  }

  .price-calendar__day--empty,
  .price-calendar__day--past {
    display: none;
  }

  .price-calendar__day-num {
    font-size: 14px;
  }

  .price-calendar__day-price {
    font-size: 12px;
    margin-top: 0;
  }
}

/* ── Reduced motion ────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .price-calendar__day--selected {
    transform: none;
  }

  .price-calendar__skeleton-cell,
  .price-calendar__skeleton-title {
    animation: none;
  }

  .price-calendar__day {
    animation: none;
  }

  .price-calendar__month {
    transition: none;
  }
}

/* ── Unknown, approximate and waiting days ─────────────────────────────── */

.price-calendar__day--unknown .price-calendar__day-price {
  color: var(--text3);
  font-weight: 700;
}

.price-calendar__day--pending .price-calendar__day-price,
.cal-day-price--waiting,
.pcal-p.pending,
.pcal-p.dots {
  animation: pcalPulse 1.4s ease-in-out infinite;
}

@keyframes pcalPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.price-calendar__legend-mark,
.cal-legend-mark {
  display: inline-block;
  min-width: 8px;
  text-align: center;
  font-weight: 700;
  color: var(--text3);
}

/* ── Date strip: days that have gone, keyboard focus ───────────────────── */

.pcal-day.past {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.pcal-day:focus-visible,
.cal-day:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .price-calendar__day--pending .price-calendar__day-price,
  .cal-day-price--waiting,
  .pcal-p.pending,
  .pcal-p.dots {
    animation: none;
  }
}
