/**
 * BookingSearchWidget Styles — Стили единого модуля поиска
 * Все селекторы строго изолированы под .hg-booking-search.
 */

.hg-booking-search {
  --hg-primary: var(--brand-primary, var(--color-primary, #0B5FA5));
  --hg-primary-hover: var(--brand-primary-hover, var(--color-primary-dark, #084980));
  --hg-bg: var(--brand-surface, var(--color-surface, #FCFCFD));
  --hg-bg-alt: var(--brand-bg-alt, #F4F8FB);
  --hg-text: var(--brand-text, var(--color-text, #1B2A3A));
  --hg-text-muted: var(--brand-text-muted, var(--color-text-muted, #536B82));
  --hg-text-inverse: var(--brand-text-inverse, var(--hg-bg));
  --hg-border: var(--brand-border, var(--color-border, var(--hg-bg-alt)));
  --hg-border-focus: var(--brand-primary, var(--hg-primary));
  --hg-error: var(--color-error, var(--hg-primary-hover));
  --hg-error-bg: var(--color-error-bg, var(--hg-bg-alt));
  --hg-range-bg: var(--badge-bg, rgba(11, 95, 165, 0.12));
  --hg-radius: var(--radius-md, 8px);
  --hg-radius-lg: var(--radius-lg, 12px);
  --hg-shadow: var(--shadow-md, 0 4px 16px rgba(0, 0, 0, 0.08));
  --hg-touch-min: 44px;

  position: relative;
  font-family: inherit;
  color: var(--hg-text);
  box-sizing: border-box;
  width: 100%;
}

.hg-booking-search *,
.hg-booking-search *::before,
.hg-booking-search *::after {
  box-sizing: border-box;
}

/* Строка поиска */
.hg-booking-search .hg-search-bar {
  display: grid;
  grid-template-columns: 2fr 1.5fr auto;
  gap: 12px;
  background: var(--hg-bg);
  border: 1px solid var(--hg-border);
  border-radius: var(--hg-radius-lg);
  padding: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  align-items: end;
}

/* Поле ввода */
.hg-booking-search .hg-field {
  position: relative;
  display: flex;
  flex-direction: column;
}

.hg-booking-search .hg-field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--hg-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hg-booking-search .hg-icon {
  stroke: var(--hg-primary);
  flex-shrink: 0;
}

.hg-booking-search .hg-trigger-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: var(--hg-touch-min);
  padding: 10px 14px;
  background: var(--hg-bg-alt);
  border: 1px solid var(--hg-border);
  border-radius: var(--hg-radius);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--hg-text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.hg-booking-search .hg-trigger-btn:hover {
  background: var(--hg-bg-alt);
  border-color: var(--hg-border);
}

.hg-booking-search .hg-trigger-btn:focus-visible,
.hg-booking-search .hg-field.is-active .hg-trigger-btn {
  outline: none;
  background: var(--hg-bg);
  border-color: var(--hg-border-focus);
  box-shadow: 0 0 0 3px rgba(11, 95, 165, 0.15);
}

.hg-booking-search .hg-nights-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--hg-range-bg);
  color: var(--hg-primary);
  padding: 2px 8px;
  border-radius: 9999px;
  white-space: nowrap;
}

/* Ошибки валидации */
.hg-booking-search .hg-field.has-error .hg-trigger-btn {
  border-color: var(--hg-error) !important;
  background: var(--hg-error-bg) !important;
}

.hg-booking-search .hg-field-error {
  font-size: 0.75rem;
  color: var(--hg-error);
  margin-top: 4px;
  font-weight: 500;
}

/* Кнопка отправки */
.hg-booking-search .hg-search-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--hg-touch-min);
  padding: 12px 28px;
  background: var(--hg-primary);
  color: var(--hg-text-inverse);
  border: none;
  border-radius: var(--hg-radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.05s ease;
}

.hg-booking-search .hg-search-submit-btn:hover {
  background: var(--hg-primary-hover);
}

.hg-booking-search .hg-search-submit-btn:active {
  transform: translateY(1px);
}

.hg-booking-search .hg-search-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.hg-booking-search .hg-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(252, 252, 253, 0.3);
  border-top-color: var(--hg-text-inverse);
  border-radius: 50%;
  animation: hg-spin 0.6s linear infinite;
}

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

/* Выпадающие окна (попапы) */
.hg-booking-search .hg-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--hg-bg);
  border: 1px solid var(--hg-border);
  border-radius: var(--hg-radius-lg);
  box-shadow: var(--hg-shadow);
  z-index: 1000;
  padding: 16px;
  animation: hg-fade-in 0.15s ease-out;
}

@keyframes hg-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Попап календаря */
.hg-booking-search .hg-popover-calendar {
  width: auto;
  min-width: 320px;
}

.hg-booking-search .hg-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hg-booking-search .hg-calendar-summary {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--hg-text);
  text-align: center;
}

.hg-booking-search .hg-cal-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--hg-border);
  background: var(--hg-bg);
  border-radius: 50%;
  cursor: pointer;
  color: var(--hg-text);
  transition: background 0.15s ease;
}

.hg-booking-search .hg-cal-nav-btn:hover:not(:disabled) {
  background: var(--hg-bg-alt);
}

.hg-booking-search .hg-cal-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.hg-booking-search .hg-cal-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hg-booking-search .hg-popover-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--hg-border);
  background: var(--hg-bg);
  border-radius: 50%;
  cursor: pointer;
  color: var(--hg-text-muted);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.hg-booking-search .hg-popover-close-btn:hover {
  background: var(--hg-bg-alt);
  color: var(--hg-text);
  border-color: var(--hg-text);
}

.hg-booking-search .hg-calendar-months {
  display: flex;
  gap: 24px;
}

.hg-booking-search .hg-cal-month {
  width: 260px;
}

.hg-booking-search .hg-cal-month-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--hg-text);
}

.hg-booking-search .hg-cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
}

.hg-booking-search .hg-cal-dow {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--hg-text-muted);
  padding: 4px 0;
}

.hg-booking-search .hg-cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.hg-booking-search .hg-cal-day {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--hg-text);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s ease, color 0.1s ease;
}

.hg-booking-search .hg-cal-day:hover:not(.is-disabled):not(.is-empty) {
  background: var(--hg-bg-alt);
}

.hg-booking-search .hg-cal-day.is-empty {
  cursor: default;
}

.hg-booking-search .hg-cal-day.is-disabled {
  color: var(--hg-text-muted);
  cursor: not-allowed;
  text-decoration: line-through;
}

.hg-booking-search .hg-cal-day.is-range-start {
  background: var(--hg-primary) !important;
  color: var(--hg-text-inverse) !important;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  font-weight: 700;
}

.hg-booking-search .hg-cal-day.is-range-end {
  background: var(--hg-primary) !important;
  color: var(--hg-text-inverse) !important;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  font-weight: 700;
}

.hg-booking-search .hg-cal-day.is-range-start.is-range-end {
  border-radius: 4px !important;
}

.hg-booking-search .hg-cal-day.is-in-range,
.hg-booking-search .hg-cal-day.is-hover-range {
  background: var(--hg-range-bg) !important;
  color: var(--hg-primary) !important;
  border-radius: 0;
}

.hg-booking-search .hg-calendar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--hg-border);
}

.hg-booking-search .hg-cal-nights-info {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--hg-primary);
}

.hg-booking-search .hg-cal-actions {
  display: flex;
  gap: 8px;
}

.hg-booking-search .hg-btn {
  min-height: 36px;
  padding: 6px 16px;
  border-radius: var(--hg-radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.hg-booking-search .hg-btn-secondary {
  background: var(--hg-bg-alt);
  color: var(--hg-text);
  border: 1px solid var(--hg-border);
}

.hg-booking-search .hg-btn-secondary:hover {
  background: var(--hg-bg-alt);
}

.hg-booking-search .hg-btn-primary {
  background: var(--hg-primary);
  color: var(--hg-text-inverse);
  border: 1px solid var(--hg-primary);
}

.hg-booking-search .hg-btn-primary:hover {
  background: var(--hg-primary-hover);
}

.hg-booking-search .hg-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hg-booking-search .hg-btn-block {
  width: 100%;
}

/* Попап выбора гостей */
.hg-booking-search .hg-popover-guests {
  width: 320px;
}

.hg-booking-search .hg-guests-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--hg-border);
}

.hg-booking-search .hg-guests-header-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--hg-text);
}

.hg-booking-search .hg-guests-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--hg-border);
}

.hg-booking-search .hg-guests-label-wrap {
  display: flex;
  flex-direction: column;
}

.hg-booking-search .hg-guests-title {
  font-size: 0.95rem;
  color: var(--hg-text);
}

.hg-booking-search .hg-guests-subtitle {
  font-size: 0.75rem;
  color: var(--hg-text-muted);
}

.hg-booking-search .hg-counter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hg-booking-search .hg-counter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--hg-border);
  background: var(--hg-bg);
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--hg-text);
  cursor: pointer;
  transition: background 0.15s ease;
}

.hg-booking-search .hg-counter-btn:hover:not(:disabled) {
  background: var(--hg-bg-alt);
  border-color: var(--hg-border);
}

.hg-booking-search .hg-counter-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.hg-booking-search .hg-counter-val {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Блок возрастов детей */
.hg-booking-search .hg-children-ages-block {
  margin-top: 12px;
  padding: 12px;
  background: var(--hg-bg-alt);
  border-radius: var(--hg-radius);
}

.hg-booking-search .hg-children-ages-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--hg-text-muted);
  margin-bottom: 8px;
}

.hg-booking-search .hg-children-ages-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hg-booking-search .hg-child-age-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hg-booking-search .hg-child-age-lbl {
  font-size: 0.875rem;
  color: var(--hg-text);
}

.hg-booking-search .hg-child-age-select {
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--hg-border);
  border-radius: var(--hg-radius);
  background: var(--hg-bg);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--hg-text);
  cursor: pointer;
}

.hg-booking-search .hg-guests-footer {
  margin-top: 16px;
}

.hg-booking-search .hidden {
  display: none !important;
}

/* Мобильная адаптация (< 768px) */
@media (max-width: 767px) {
  .hg-booking-search .hg-search-bar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .hg-booking-search .hg-trigger-btn {
    min-height: 48px;
    font-size: 1rem;
  }

  .hg-booking-search .hg-popover {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  }

  .hg-booking-search .hg-calendar-months {
    flex-direction: column;
  }

  .hg-booking-search .hg-cal-month {
    width: 100%;
  }

  .hg-booking-search .hg-cal-day {
    height: 44px;
    font-size: 1rem;
  }

  .hg-booking-search .hg-search-submit-btn {
    min-height: 48px;
    width: 100%;
    font-size: 1.05rem;
  }

  .hg-booking-search .hg-popover-close-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
}
