/**
 * Price History Popover Styles
 */

/* ── Popover Container ──────────────────────────────────────────── */
.ph-popover {
  position: fixed;
  z-index: 100000;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ph-popover.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Arrow ───────────────────────────────────────────────────────── */
.ph-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  display: none;
}
.ph-arrow.ph-arrow-top {
  display: block;
  top: -6px;
  box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.06);
}
.ph-arrow.ph-arrow-bottom {
  display: block;
  bottom: -6px;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.06);
}

/* ── Header ──────────────────────────────────────────────────────── */
.ph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.ph-title {
  font-weight: 600;
  font-size: 14px;
  color: #333;
}
.ph-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  transition: all 0.15s;
}
.ph-close:hover {
  background: #f5f5f5;
  color: #333;
}

/* ── Filter Checkbox ─────────────────────────────────────────────── */
.ph-filter {
  padding: 8px 14px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.ph-filter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  user-select: none;
}
.ph-filter-cb {
  accent-color: #2E7D32;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── Body (scrollable) ───────────────────────────────────────────── */
.ph-body {
  overflow-y: auto;
  flex: 1;
  padding: 6px 0;
}

/* ── Group ────────────────────────────────────────────────────────── */
.ph-group {
  margin: 0;
}
.ph-group + .ph-group {
  border-top: 1px solid #f0f0f0;
}
.ph-group-header {
  padding: 8px 14px 4px;
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ph-group-current .ph-group-header {
  color: #2E7D32;
}
.ph-badge-current {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  background: #E8F5E9;
  color: #2E7D32;
  padding: 1px 6px;
  border-radius: 8px;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Row (each price entry) ──────────────────────────────────────── */
.ph-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.12s;
  gap: 8px;
}
.ph-row:hover {
  background: #f0f7ff;
}
.ph-row-selected {
  background: #E8F5E9 !important;
}
.ph-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.ph-row-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ph-date {
  font-size: 13px;
  color: #666;
  white-space: nowrap;
}
.ph-qty {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
}
.ph-price {
  font-size: 14px;
  font-weight: 600;
  color: #2E7D32;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ph-select {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid #2E7D32;
  background: transparent;
  color: #2E7D32;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.ph-select:hover {
  background: #2E7D32;
  color: #fff;
  transform: scale(1.1);
}

/* ── Empty / Loading / Error ─────────────────────────────────────── */
.ph-empty {
  text-align: center;
  padding: 24px 16px;
  color: #999;
  font-size: 13px;
}
.ph-error {
  color: #C62828;
}
.ph-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.ph-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #eee;
  border-top-color: #2E7D32;
  border-radius: 50%;
  animation: phSpin 0.7s linear infinite;
}
@keyframes phSpin {
  to { transform: rotate(360deg); }
}

/* ── Lupe/Trigger Button (shared) ────────────────────────────────── */
.ph-trigger {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: all 0.15s;
  opacity: 0.55;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.ph-trigger:hover {
  opacity: 1;
  background: rgba(46, 125, 50, 0.08);
  border-color: rgba(46, 125, 50, 0.25);
}
.ph-trigger svg {
  width: 16px;
  height: 16px;
  stroke: #2E7D32;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Dark Mode ────────────────────────────────────────────────────── */
[data-theme="dark"] .ph-popover {
  background: #2a2a2a;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .ph-arrow {
  background: #2a2a2a;
}
[data-theme="dark"] .ph-header {
  border-color: #444;
}
[data-theme="dark"] .ph-title {
  color: #e0e0e0;
}
[data-theme="dark"] .ph-close {
  color: #bbb;
}
[data-theme="dark"] .ph-close:hover {
  background: #3a3a3a;
  color: #e0e0e0;
}
[data-theme="dark"] .ph-filter {
  border-color: #444;
}
[data-theme="dark"] .ph-filter-label {
  color: #bbb;
}
[data-theme="dark"] .ph-group + .ph-group {
  border-color: #444;
}
[data-theme="dark"] .ph-group-header {
  color: #999;
}
[data-theme="dark"] .ph-group-current .ph-group-header {
  color: #81C784;
}
[data-theme="dark"] .ph-badge-current {
  background: #1b3a1b;
  color: #81C784;
}
[data-theme="dark"] .ph-row:hover {
  background: #333;
}
[data-theme="dark"] .ph-row-selected {
  background: #1b3a1b !important;
}
[data-theme="dark"] .ph-date {
  color: #bbb;
}
[data-theme="dark"] .ph-qty {
  color: #888;
}
[data-theme="dark"] .ph-price {
  color: #81C784;
}
[data-theme="dark"] .ph-select {
  border-color: #81C784;
  color: #81C784;
}
[data-theme="dark"] .ph-select:hover {
  background: #81C784;
  color: #1a1a1a;
}
[data-theme="dark"] .ph-empty {
  color: #888;
}
[data-theme="dark"] .ph-spinner {
  border-color: #444;
  border-top-color: #81C784;
}
[data-theme="dark"] .ph-trigger:hover {
  background: rgba(129, 199, 132, 0.1);
  border-color: rgba(129, 199, 132, 0.3);
}
[data-theme="dark"] .ph-trigger svg {
  stroke: #81C784;
}

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ph-popover {
    left: 8px !important;
    right: 8px;
    width: auto !important;
    max-height: 60vh;
  }
}
