/**
 * f-calendar.css — Agenda de visitas · glass fino, mes completo, móvil armónico
 */
.kpk-calendar-widget {
  position: fixed;
  bottom: 20px;
  left: 18px;
  right: auto;
  z-index: 10006;
  width: min(340px, calc(100vw - 24px));
  max-height: min(82vh, 620px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.18) inset,
    0 -1px 0 rgba(0, 0, 0, 0.12) inset;
  font-family: 'Outfit', -apple-system, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  color: #fff;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.kpk-calendar-widget.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.kpk-calendar-widget.is-success {
  justify-content: center;
  min-height: 220px;
}

.kpk-cal__handle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 8px;
  background: transparent;
  border-bottom: none;
}

.kpk-cal__eyebrow {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(125, 211, 252, 0.95);
}

.kpk-cal__title {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.kpk-cal__sub {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.62);
  transition: color 0.25s ease;
}

.kpk-cal__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.75);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.kpk-cal__close:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.kpk-cal__body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: min(64vh, 480px);
  -webkit-overflow-scrolling: touch;
}

.kpk-cal__step-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 7px;
}
.kpk-cal__step-hint {
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(255, 255, 255, 0.38);
  margin-left: 4px;
}

/* Lotes — botones (no pills tipo barra) */
.kpk-cal__lotes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 96px;
  overflow-y: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.kpk-cal__lote-chip {
  flex-shrink: 0;
  min-height: 30px;
  padding: 6px 11px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.kpk-cal__lote-chip:hover {
  background: rgba(255, 255, 255, 0.16);
}
.kpk-cal__lote-chip.is-selected {
  background: rgba(0, 180, 255, 0.88);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 180, 255, 0.28);
}
.kpk-cal__lote-chip.is-pop {
  animation: kpk-cal-lote-pop 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes kpk-cal-lote-pop {
  0% { transform: scale(0.9); }
  55% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Días — grilla de botones (sin barra/scroll horizontal tipo nav) */
.kpk-cal__days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  max-height: none;
  overflow: visible;
  padding: 0;
  scroll-snap-type: none;
}

.cal-day-btn {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 4px 2px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}
.cal-day-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  transform: translateY(-1px);
}
.cal-day-btn:active {
  transform: scale(0.97);
}
.cal-day-btn.is-selected {
  background: rgba(0, 180, 255, 0.88);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  box-shadow: 0 3px 12px rgba(0, 180, 255, 0.3);
}
.cal-day-sem {
  font-size: 8.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.85;
}
.cal-day-num {
  font-size: 13px;
  font-weight: 700;
  margin-top: 1px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpk-cal__hours {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.cal-hour-btn {
  -webkit-appearance: none;
  appearance: none;
  height: 34px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font-size: 11.5px;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}
.cal-hour-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  transform: translateY(-1px);
}
.cal-hour-btn:active {
  transform: scale(0.97);
}
.cal-hour-btn.is-selected {
  background: rgba(0, 180, 255, 0.88);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  box-shadow: 0 3px 12px rgba(0, 180, 255, 0.28);
}

.kpk-cal__fields {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.kpk-cal__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.kpk-cal__input {
  width: 100%;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  padding: 0 11px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.kpk-cal__input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}
.kpk-cal__input:focus {
  border-color: rgba(0, 180, 255, 0.65);
  background: rgba(0, 0, 0, 0.32);
}

.kpk-cal__summary {
  margin: 0;
  padding: 8px 10px;
  border-radius: 11px;
  background: rgba(0, 180, 255, 0.12);
  border: 1px solid rgba(0, 180, 255, 0.22);
  font-size: 11px;
  line-height: 1.4;
  color: rgba(245, 245, 247, 0.92);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.kpk-cal__summary.is-flash {
  animation: kpk-cal-summary-flash 0.55s ease;
}
@keyframes kpk-cal-summary-flash {
  0% { box-shadow: 0 0 0 0 rgba(0, 180, 255, 0.45); border-color: rgba(0, 180, 255, 0.55); }
  100% { box-shadow: 0 0 0 0 transparent; border-color: rgba(0, 180, 255, 0.22); }
}

.kpk-cal__footer {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.kpk-cal__submit {
  width: 100%;
  height: 38px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(0, 180, 255, 0.95), rgba(0, 120, 255, 0.9));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 120, 255, 0.24);
  transition: filter 0.15s ease, transform 0.15s ease;
}
.kpk-cal__submit:hover:not(:disabled) {
  filter: brightness(1.06);
}
.kpk-cal__submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.kpk-cal__hint {
  margin: 0;
  font-size: 10px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}

/* Success */
.kpk-cal__success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 22px;
  gap: 8px;
  animation: kpk-cal-success-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes kpk-cal-success-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.kpk-cal__success-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: rgba(34, 197, 94, 0.85);
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
  margin-bottom: 4px;
}
.kpk-cal__success-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.kpk-cal__success-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.72);
  max-width: 280px;
}

@media (max-width: 720px) {
  .kpk-calendar-widget {
    left: 50%;
    right: auto;
    bottom: auto;
    top: max(10px, env(safe-area-inset-top, 0px) + 6px);
    width: min(360px, calc(100vw - 16px));
    max-height: min(58vh, calc(100dvh - 168px));
    transform: translateX(-50%) translateY(10px) scale(0.98);
    z-index: 10020;
    border-radius: 16px;
  }
  .kpk-calendar-widget.is-open {
    transform: translateX(-50%) translateY(0) scale(1);
  }
  .kpk-cal__body {
    max-height: min(38vh, 280px);
    padding: 8px 10px 10px;
    gap: 10px;
  }
  .kpk-cal__lotes {
    max-height: 72px;
  }
  .kpk-cal__lote-chip {
    min-height: 28px;
    font-size: 10.5px;
    padding: 5px 9px;
    border-radius: 9px;
  }
  .kpk-cal__days {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }
  .cal-day-btn {
    min-height: 40px;
    border-radius: 9px;
  }
  .cal-day-num { font-size: 12px; }
  .cal-hour-btn { height: 32px; font-size: 11px; }
  .kpk-cal__input { height: 32px; font-size: 11.5px; }
  .kpk-cal__submit { height: 36px; font-size: 12.5px; }
  .kpk-cal__row {
    grid-template-columns: 1fr;
  }
  body.kpk-calendar-open .kpk-mobile-ai-bubble-popup {
    max-height: 34vh;
  }
}

@media (min-width: 721px) {
  body.kpk-ai-open .kpk-calendar-widget {
    left: 18px;
    right: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kpk-cal__lote-chip.is-pop,
  .kpk-cal__summary.is-flash,
  .kpk-cal__success {
    animation: none !important;
  }
}
