/* ============================================
   Price History Modal
   ============================================ */

/* --- Icon Button on Item Cards --- */
.ph-icon-btn {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.7; transition: opacity 0.15s, background 0.15s;
}
.ph-icon-btn:hover { opacity: 1; background: rgba(0,0,0,0.8); }

/* --- Animations --- */
@keyframes ph-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes ph-slide-up { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
@keyframes ph-sheet-up { from { transform: translateY(100%) } to { transform: translateY(0) } }
@keyframes ph-pulse { 0%, 100% { opacity: 0.4 } 50% { opacity: 1 } }

/* --- Overlay + Card --- */
.ph-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  animation: ph-fade-in 0.2s ease;
}

.ph-card {
  background: var(--white, #fafafa);
  border: 3px solid var(--black, #0a0a0a);
  box-shadow: 8px 8px 0 var(--black, #0a0a0a);
  border-radius: 8px;
  max-width: 680px; width: 95%; max-height: 85vh;
  overflow-y: auto;
  animation: ph-slide-up 0.25s ease;
}

/* --- Header --- */
.ph-header {
  background: var(--cream, #fff8f0);
  border-bottom: 2px solid var(--black, #0a0a0a);
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
}

.ph-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  margin: 0;
}

.ph-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--black, #0a0a0a); color: var(--white, #fafafa);
  border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; line-height: 1;
}

.ph-header-title {
  font-weight: 700; font-size: 0.95rem; line-height: 1.3;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ph-body { overflow-y: auto; flex: 1; padding: 1rem 1.25rem; }

/* --- Stats Bar --- */
.ph-stats {
  font-family: 'Space Mono', monospace; font-size: 0.72rem; color: #555;
  margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: 6px 14px;
}

/* --- Chart --- */
.ph-svg {
  width: 100%; height: 200px; display: block;
  border: 1px solid #e5e5e5; border-radius: 4px; margin-bottom: 0.75rem;
}

/* --- Legend --- */
.ph-legend {
  display: flex; flex-wrap: wrap; gap: 1rem;
  padding: 0 1.25rem 0.75rem;
}

.ph-legend-item {
  display: flex; align-items: center; gap: 0.35rem;
  font-family: 'Space Mono', monospace; font-size: 0.6rem;
}

.ph-legend-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}

/* --- Table --- */
.ph-table-wrap {
  overflow-x: auto; max-height: 260px; overflow-y: auto;
  border: 1px solid #e5e5e5; border-radius: 4px;
}

.ph-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.72rem;
}

.ph-table th {
  position: sticky; top: 0; background: #f9f9f9;
  font-family: 'Space Grotesk', sans-serif; font-weight: 700;
  text-align: left; padding: 6px 8px;
  border-bottom: 2px solid #ddd;
}

.ph-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

/* --- Condition Badge --- */
.ph-condition {
  display: inline-block;
  padding: 2px 6px; border-radius: 3px;
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em;
}

/* --- Utility classes (used by JS rendering) --- */
.ph-mono { font-family: 'Space Mono', monospace; }
.ph-bold { font-weight: 700; }
.ph-event { font-family: 'Space Grotesk', sans-serif; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-pill { font-family: 'Space Mono', monospace; font-size: 0.6rem; padding: 2px 7px; border-radius: 99px; white-space: nowrap; font-weight: 600; }
.ph-single-note { font-size: 0.78rem; color: #666; margin-top: 0.75rem; line-height: 1.5; font-family: 'Space Grotesk', sans-serif; }
.lo { color: #16a34a; font-weight: 700; }
.hi { color: #dc2626; font-weight: 700; }

/* --- Empty / Loading States --- */
.ph-empty {
  text-align: center; padding: 2rem 1.25rem;
  color: #888;
  font-family: 'Space Mono', monospace; font-size: 0.75rem;
}

.ph-loading {
  text-align: center; padding: 3rem 1.25rem;
  font-family: 'Space Mono', monospace; font-size: 0.8rem;
  color: #aaa;
  animation: ph-pulse 1.5s ease-in-out infinite;
}

/* --- Mobile (bottom-sheet) --- */
@media (max-width: 600px) {
  .ph-overlay { padding: 0; align-items: flex-end; }

  .ph-card {
    max-height: 90vh; max-width: 100%;
    border-radius: 16px 16px 0 0;
    animation: ph-sheet-up 0.3s ease;
  }

  .ph-svg { height: 160px; }
  .ph-table { font-size: 0.65rem; }
  .ph-header { padding: 0.85rem 1rem; }
  .ph-body { padding: 0.85rem 1rem; }
  .ph-event { max-width: 120px; }
}
