/**
 * Anwar Saeed Travel — Phase 2 widgets.
 * Styles for the flight departure calendar (.ast-cal*) and the Saeed
 * chatbot widget (.ast-saeed*). Uses the theme CSS variables from
 * style.css. Light-only theme; no dark-mode variants. No emojis.
 */

/* ------------------------------------------------------------------ */
/* Shared                                                              */
/* ------------------------------------------------------------------ */

/* The panel rule below sets display:flex, which would override the
   browser's built-in [hidden] { display:none } — so the panel's own
   [hidden] must be listed here too. Without it the chat panel was
   visible on every page load and the close button could not hide it. */
.ast-saeed[hidden],
.ast-saeed__panel[hidden],
.ast-cal__popup[hidden] {
  display: none;
}

/* The theme does not define this yet; the Saeed form label needs it. */
.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ */
/* Flight departure calendar                                           */
/* ------------------------------------------------------------------ */

.ast-cal {
  position: relative;
}

.ast-cal__button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.ast-cal__button svg {
  flex-shrink: 0;
  color: var(--muted);
}

.ast-cal__popup {
  position: absolute;
  z-index: 50;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.5rem;
  width: min(92vw, 680px);
  max-height: 85vh;
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-hero);
}

.ast-cal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.ast-cal__title {
  margin: 0;
  font-weight: 700;
  color: var(--navy-900);
}

.ast-cal__close {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.ast-cal__close:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.ast-cal__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.ast-cal__nav-btn {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9999px;
  background: var(--bg);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.ast-cal__nav-btn:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: var(--gold-500);
}

.ast-cal__nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ast-cal__range {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

.ast-cal__range-sep {
  color: var(--muted);
  margin: 0 0.25rem;
}

.ast-cal__months {
  display: grid;
  gap: 1.5rem;
}

.ast-cal__month-title {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--navy-900);
  text-align: center;
}

.ast-cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  text-align: center;
}

.ast-cal__weekday {
  display: grid;
  place-items: center;
  height: 2rem;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.ast-cal__blank {
  display: block;
}

.ast-cal__day {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.ast-cal__day:hover:not(:disabled) {
  background: var(--bg-soft);
}

.ast-cal__day:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--gold);
}

/* Past dates are disabled. */
.ast-cal__day.is-past {
  color: #cbd5e1;
  cursor: not-allowed;
}

/* A flight exists on this date for the chosen route. */
.ast-cal__day.is-available {
  box-shadow: 0 0 0 2px var(--green);
  background: #ecfdf5;
  color: #065f46;
  font-weight: 600;
}

.ast-cal__day.is-available:hover:not(:disabled) {
  background: #d1fae5;
}

/* Today. */
.ast-cal__day.is-today {
  box-shadow: 0 0 0 1px var(--gold-600);
  font-weight: 700;
}

/* Selected date: navy with white text, plus the green ring when a flight
   also exists on it. */
.ast-cal__day.is-selected {
  background: var(--navy-900);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--navy-900);
}

.ast-cal__day.is-selected.is-available {
  box-shadow: 0 0 0 2px var(--green), 0 0 0 4px var(--bg);
}

.ast-cal__day.is-selected.is-today {
  box-shadow: 0 0 0 2px var(--navy-900);
}

.ast-cal__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--muted);
}

.ast-cal__legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.ast-cal__swatch {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
}

.ast-cal__swatch--available {
  box-shadow: 0 0 0 2px var(--green);
  background: #ecfdf5;
}

.ast-cal__swatch--selected {
  background: var(--navy-900);
}

.ast-cal__swatch--today {
  box-shadow: 0 0 0 1px var(--gold-600);
  background: var(--bg);
}

.ast-cal__count {
  margin-left: auto;
  font-weight: 500;
  color: var(--green);
}

.ast-cal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
}

.ast-cal__clear {
  padding: 0.25rem 0.5rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.ast-cal__clear:hover {
  color: var(--navy-900);
}

.ast-cal__done {
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
}

/* ------------------------------------------------------------------ */
/* Saeed chatbot widget                                                */
/* ------------------------------------------------------------------ */

.ast-saeed {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
}

.ast-saeed__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: var(--gold);
  color: var(--navy-900);
  box-shadow: var(--shadow-hero);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.ast-saeed__toggle:hover {
  background: var(--gold-500);
}

.ast-saeed__toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--gold), 0 0 0 4px var(--bg);
}

.ast-saeed__panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 2rem));
  max-height: 70vh;
  margin-bottom: 0.75rem;
  overflow: hidden;
  border: 1px solid rgba(10, 25, 49, 0.1);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-hero);
}

.ast-saeed__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--navy-900);
  color: #ffffff;
}

.ast-saeed__avatar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  background: var(--gold);
  color: var(--navy-900);
  font-size: 0.875rem;
  font-weight: 700;
}

.ast-saeed__header > div {
  min-width: 0;
  flex: 1;
}

.ast-saeed__name {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.25;
}

.ast-saeed__status {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
}

.ast-saeed__dot {
  width: 0.5rem;
  height: 0.5rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background: #34d399;
}

.ast-saeed__close {
  padding: 0.375rem;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.ast-saeed__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.ast-saeed__messages {
  flex: 1;
  min-height: 240px;
  overflow-y: auto;
  padding: 0.75rem;
  background: var(--bg-soft);
}

.ast-saeed__row {
  display: flex;
  margin-bottom: 0.5rem;
}

.ast-saeed__row--user {
  justify-content: flex-end;
}

.ast-saeed__row--bot {
  justify-content: flex-start;
}

.ast-saeed__bubble {
  max-width: 85%;
  padding: 0.5rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
}

.ast-saeed__bubble--user {
  border-bottom-right-radius: 0.25rem;
  background: var(--gold);
  color: var(--navy-900);
}

.ast-saeed__bubble--bot {
  border-bottom-left-radius: 0.25rem;
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(10, 25, 49, 0.1);
}

.ast-saeed__text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.ast-saeed__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.ast-saeed__link {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  background: var(--navy-900);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.ast-saeed__link:hover {
  background: var(--navy-800);
}

.ast-saeed__link--wa {
  background: var(--green);
  color: #ffffff;
}

.ast-saeed__link--wa:hover {
  background: #047857;
}

.ast-saeed__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.ast-saeed__chip {
  padding: 0.25rem 0.625rem;
  border: 1px solid rgba(10, 25, 49, 0.2);
  border-radius: 9999px;
  background: var(--bg);
  color: var(--navy-900);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.ast-saeed__chip:hover {
  background: var(--gold);
  border-color: var(--gold);
}

.ast-saeed__typing {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.625rem 0.75rem;
  border-radius: 1rem;
  border-bottom-left-radius: 0.25rem;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(10, 25, 49, 0.1);
}

.ast-saeed__typing span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: rgba(10, 25, 49, 0.5);
  animation: ast-saeed-bounce 1s infinite;
}

.ast-saeed__typing span:nth-child(2) {
  animation-delay: 150ms;
}

.ast-saeed__typing span:nth-child(3) {
  animation-delay: 300ms;
}

@keyframes ast-saeed-bounce {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }

  50% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.ast-saeed__form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.ast-saeed__form input {
  min-width: 0;
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 9999px;
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 0.875rem;
  outline: none;
}

.ast-saeed__form input::placeholder {
  color: var(--muted);
}

.ast-saeed__form input:focus {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 2px rgba(245, 196, 81, 0.5);
}

.ast-saeed__form button[type="submit"] {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: var(--gold);
  color: var(--navy-900);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.ast-saeed__form button[type="submit"]:hover {
  background: var(--gold-500);
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (min-width: 640px) {
  .ast-cal__popup {
    left: auto;
    right: 0;
    transform: none;
    padding: 1.25rem;
  }

  .ast-cal__months {
    grid-template-columns: repeat(2, 1fr);
  }

  .ast-cal__day {
    width: 2.5rem;
    height: 2.5rem;
  }

  .ast-saeed {
    right: 1.5rem;
    bottom: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ast-saeed__typing span {
    animation: none;
  }
}
