/* Цвета из настроек модуля приходят inline-переменными на .price-history-widget и .ph-modal (модалка переносится в body) */
.price-history-widget,
.ph-modal {
  --ph-accent: #0071e3;
  --ph-accent-soft: #ebf3fc;
  --ph-accent-ring: rgba(0, 113, 227, 0.15);
  --ph-accent-ink: #ffffff;
  --ph-accent-text: #0071e3;
  --ph-line: #0071e3;
  --ph-point: #0071e3;
}

/* ==========================================================================
   PRICE HISTORY WIDGET — APPLE HIG / macOS DESIGN SYSTEM
   Clean surfaces, SF Pro typography, native segmented controls, no liquid glass
   ========================================================================== */
.price-history-widget {
  display: block;
  margin: 18px 0 24px 0;
  padding: 18px 20px 16px 20px;
  background: #ffffff;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.02);
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  max-width: 100%;
  clear: both;
}

.price-history-widget * {
  box-sizing: border-box;
}

/* Header: заголовок на всю ширину, ниже бейдж и переключатели */
.ph-header {
  margin-bottom: 12px;
}

.ph-eyebrow {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #86868b;
  line-height: 1.2;
}

.ph-period-subtitle {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
  line-height: 1.3;
  letter-spacing: -0.2px;
}

/* Apple Status Badge */
.ph-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 10px;
  padding: 4px 10px;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.1px;
  transition: all 0.2s ease;
}

.ph-badge-best {
  background: #e8f8ee;
  color: #1b873f;
}

.ph-badge-good {
  background: #ebf3fc;
  color: #0071e3;
}

.ph-badge-high {
  background: #fdf4e7;
  color: #b25e00;
}

.ph-badge-above {
  background: #fdf0ec;
  color: #c93400;
}

.ph-badge-normal {
  background: #f2f2f7;
  color: #636366;
}

.ph-badge-icon {
  font-size: 12px;
  line-height: 1;
}

.ph-badge-icon-svg {
  display: inline-block;
  vertical-align: middle;
}

/* Apple Segmented Controls Row */
.ph-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ph-segmented {
  display: flex;
  width: 100%;
  background: #f2f2f7;
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.ph-seg-btn {
  flex: 1 1 auto;
  white-space: nowrap;
  text-align: center;
  border: none;
  background: transparent;
  color: #636366;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 6px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.3;
  outline: none;
  user-select: none;
  font-family: inherit;
}

.ph-seg-btn:hover {
  color: #1d1d1f;
}

.ph-seg-btn.active {
  background: #ffffff;
  color: #1d1d1f;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0.5px 1px rgba(0, 0, 0, 0.04);
}

.ph-chart-container {
  position: relative;
  width: 100%;
  min-height: 190px;
  background: #ffffff;
  overflow: visible;
}

.ph-svg-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  cursor: crosshair;
}

.ph-svg {
  display: block;
  max-width: none;
  height: auto;
  overflow: visible;
  cursor: crosshair;
}

/* Apple SVG Guidelines & Curves */
.ph-guideline {
  stroke: #f2f2f7;
  stroke-width: 1;
}

.ph-guideline-static {
  opacity: 0.9;
}

.ph-baseline {
  stroke: #e5e5ea;
  stroke-width: 1;
}

.ph-curve-line {
  fill: none;
  stroke: var(--ph-line, #0071e3);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease;
}

.ph-curve-area {
  pointer-events: none;
}

.ph-point {
  fill: #ffffff;
  stroke: var(--ph-point, #0071e3);
  stroke-width: 2;
  cursor: pointer;
  transition: transform 0.15s ease, r 0.15s ease, stroke-width 0.15s ease;
}

/* Много точек (недели за 1–2 года): маркеры не рисуем, остаётся линия; точка видна при наведении и последняя */
.ph-point-dense {
  opacity: 0;
}

.ph-point-dense.hovered {
  opacity: 1;
}

.ph-point:hover,
.ph-point.hovered {
  r: 5.5;
  stroke-width: 2.5;
  fill: #ffffff;
}

/* Apple Scrubber: Vertical Hairline & Halo Ring */
.ph-hover-guideline {
  stroke: #8e8e93;
  stroke-width: 1;
  stroke-dasharray: 2, 2;
}

.ph-hover-halo {
  fill: var(--ph-point, #0071e3);
  fill-opacity: 0.16;
  stroke: none;
}

.ph-label-text {
  font-size: 11px;
  font-weight: 400;
  fill: #86868b;
  text-anchor: middle;
  font-family: inherit;
  pointer-events: none;
  user-select: none;
}

.ph-label-text.current-date {
  font-weight: 600;
  fill: #1d1d1f;
}

/* macOS Popover Tooltip */
.ph-tooltip {
  position: absolute;
  z-index: 100;
  pointer-events: none;
  background: #ffffff;
  color: #1d1d1f;
  padding: 6px 10px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.06);
  transform: translate(-50%, -100%);
  margin-top: -10px;
  text-align: center;
  white-space: nowrap;
}

.ph-tip-price {
  font-size: 13px;
  font-weight: 700;
  color: #1d1d1f;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.ph-tip-date {
  font-size: 11px;
  color: #86868b;
  font-weight: 400;
  margin-top: 2px;
}

.ph-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}

/* Apple Footer Bar: Corridor (Min / Avg / Max) */
.ph-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #fbfbfd;
  border-radius: 10px;
  border: 1px solid #f2f2f7;
  margin-top: 10px;
}

.ph-metric-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  text-align: center;
}

.ph-metric-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #86868b;
  margin-bottom: 2px;
}

.ph-metric-val {
  font-size: 13px;
  font-weight: 600;
  color: #1d1d1f;
  font-variant-numeric: tabular-nums;
}

.ph-val-min {
  color: #1b873f;
}

.ph-val-avg {
  color: #1d1d1f;
}

.ph-val-max {
  color: #c93400;
}

.ph-metric-divider {
  width: 1px;
  height: 22px;
  background: #e5e5ea;
}

/* Loading Overlay */
.ph-loading-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 10;
  justify-content: center;
  align-items: center;
}

.ph-loading-overlay.active {
  display: flex;
}

.ph-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #e5e5ea;
  border-top-color: var(--ph-accent, #0071e3);
  border-radius: 50%;
  animation: ph-spin 0.7s linear infinite;
}

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

@media (max-width: 600px) {
  .price-history-widget {
    padding: 14px 14px 12px 14px;
    border-radius: 14px;
  }
  .ph-seg-btn {
    padding: 5px 4px;
    font-size: 11px;
  }
  .ph-footer-bar {
    padding: 8px 10px;
  }
  .ph-metric-val {
    font-size: 12px;
  }
}

/* Кнопка подписки — в самом низу виджета, на всю ширину */
.ph-alert-footer {
  margin-top: 12px;
}

.ph-btn-alert {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  background: var(--ph-accent-soft, #ebf3fc);
  color: var(--ph-accent-text, var(--ph-accent, #0071e3));
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none !important;
  font-family: inherit;
  user-select: none;
}

.ph-btn-alert:hover {
  filter: brightness(0.96);
}

.ph-btn-alert:active {
  transform: scale(0.985);
}

.ph-alert-hint {
  margin-top: 6px;
  font-size: 12px;
  color: #86868b;
  text-align: center;
}

.ph-btn-alert .ph-bell-icon {
  stroke: currentColor;
}

/* ==========================================================================
   macOS SHEET MODAL — Native Clean Sheet Design
   ========================================================================== */
.ph-modal {
  /* базовое поведение окна не зависит от Bootstrap: тема может его не подключать */
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1055 !important;
  background: rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Открытие без Bootstrap (price_history.js добавляет класс, когда плагина modal нет) */
.ph-modal.ph-fb-open {
  display: block;
  opacity: 1;
}

body.ph-fb-lock {
  overflow: hidden;
}

.ph-modal .modal-dialog {
  z-index: 1060 !important;
}

.ph-modal-dialog {
  max-width: 400px;
  margin: 50px auto;
}

.ph-modal-sheet {
  background: #ffffff !important;
  border-radius: 18px !important;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.16) !important;
  border: none !important;
  padding: 24px 22px 20px 22px !important;
  position: relative !important;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
  -webkit-font-smoothing: antialiased;
}

/* Circular Close Button */
.ph-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f2f2f7;
  border: none;
  cursor: pointer;
  color: #86868b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  outline: none !important;
  padding: 0;
  z-index: 2;
}

.ph-modal-close:hover {
  background: #e5e5ea;
  color: #1d1d1f;
}

.ph-modal-header {
  padding: 0;
  border: none;
  text-align: center;
}

.ph-modal-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--ph-accent-soft, #ebf3fc);
  color: var(--ph-accent-text, var(--ph-accent, #0071e3));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px auto;
}

.ph-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #1d1d1f;
  margin: 0 0 4px 0;
  letter-spacing: -0.3px;
}

.ph-modal-subtitle {
  font-size: 12.5px;
  color: #86868b;
  margin: 0 0 14px 0;
  line-height: 1.35;
}

.ph-modal-body {
  padding: 0;
}

.ph-alert-product-card {
  background: #fbfbfd;
  border: 1px solid #f2f2f7;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ph-sheet-pname {
  font-size: 12px;
  font-weight: 600;
  color: #1d1d1f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.ph-sheet-pprice {
  font-size: 12px;
  color: #86868b;
  white-space: nowrap;
}

.ph-sheet-pprice strong {
  color: #1d1d1f;
}

/* Apple Segmented Channel Selector */
.ph-channel-segmented {
  display: flex;
  background: #f2f2f7;
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
  margin-bottom: 14px;
}

.ph-channel-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 2px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 7px;
  color: #636366;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  outline: none !important;
  font-family: inherit;
  user-select: none;
}

.ph-channel-tab:hover {
  color: #1d1d1f;
}

.ph-channel-tab.active {
  background: #ffffff;
  color: #1d1d1f;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0.5px 1px rgba(0, 0, 0, 0.04);
}

.ph-form-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.ph-field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ph-field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #1d1d1f;
  margin: 0;
}

.ph-input-wrapper {
  position: relative;
  width: 100%;
}

.ph-input {
  width: 100%;
  background: #f5f5f7;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #1d1d1f;
  outline: none;
  transition: all 0.15s ease;
  font-family: inherit;
  box-sizing: border-box;
}

.ph-input:focus {
  background: #ffffff;
  border-color: var(--ph-accent, #0071e3);
  box-shadow: 0 0 0 3px var(--ph-accent-ring, rgba(0, 113, 227, 0.15));
}

.ph-field-hint {
  font-size: 10.5px;
  color: #86868b;
  margin-top: 1px;
  line-height: 1.3;
}

.ph-sheet-alert {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 12px;
  line-height: 1.35;
}

.ph-sheet-error {
  background: #fdf0ec;
  color: #c93400;
}

.ph-sheet-success {
  background: #e8f8ee;
  color: #1b873f;
}

.ph-btn-apple-primary {
  width: 100%;
  background: var(--ph-accent, #0071e3);
  color: var(--ph-accent-ink, #ffffff);
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none !important;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.ph-btn-apple-primary:hover {
  filter: brightness(1.06);
}

.ph-btn-apple-primary:active {
  transform: scale(0.985);
  filter: brightness(0.94);
}


/* ---- Виджет показывается только после монтирования под блок цены (иначе мелькает внизу страницы) ---- */
.price-history-widget:not(.ph-mounted) {
  display: none;
}

/* ---- Состояние «история только начинается» ---- */
.price-history-widget .ph-empty {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #f5f5f7;
  color: #6e6e73;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}

.price-history-widget .ph-empty-line {
  display: block;
  margin-bottom: 8px;
  color: #aeaeb2;
}

.price-history-widget .ph-empty-since {
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.price-history-widget .ph-empty-note {
  color: #1d1d1f;
  font-weight: 500;
}

.price-history-widget .ph-inline-error {
  padding: 28px 12px;
  text-align: center;
  color: #6e6e73;
  font-size: 13px;
}

/* ---- Поле-ловушка для ботов: невидимо для людей ---- */
.ph-modal .ph-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---- Капча магазина внутри формы заявки ---- */
.ph-modal .ph-captcha fieldset {
  border: 0;
  margin: 0 0 12px;
  padding: 0;
  min-width: 0;
}

.ph-modal .ph-captcha legend {
  display: none;
}

.ph-modal .ph-captcha .form-group {
  margin: 0;
}

.ph-modal .ph-captcha .control-label {
  display: block;
  width: auto;
  float: none;
  padding: 0;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #6e6e73;
}

.ph-modal .ph-captcha [class*="col-sm-"] {
  float: none;
  width: auto;
  padding: 0;
}

.ph-modal .ph-captcha input[name="captcha"] {
  width: 100%;
  height: 40px;
  margin: 6px 0;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #f5f5f7;
  box-shadow: none;
}

.ph-modal .ph-captcha input[name="captcha"]:focus {
  outline: 0;
  border-color: var(--ph-accent, #0071e3);
  background: #fff;
}

.ph-modal .ph-captcha img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
}

.ph-modal .ph-captcha {
  margin-bottom: 14px;
}

/* Настройка «Рамка и тень карточки» выключена: виджет без собственной рамки и отступов — вливается в оформление темы */
.price-history-widget.ph-plain {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
