/* ============================================================
   SPOTREALTY — Glacier Light Change History Theme (Phase H4)
   ============================================================ */

/* --- Modal Overlay & Container --- */
.buyer-history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.buyer-history-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.buyer-history-dialog {
  background: #ffffff;
  width: 740px;
  max-width: 95vw;
  height: 84vh;
  max-height: 880px;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transform: scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.buyer-history-overlay.is-active .buyer-history-dialog {
  transform: scale(1);
}

/* --- Modal Header --- */
.buyer-history-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.buyer-history-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.buyer-history-title-icon {
  color: #4f46e5; /* Indigo #4f46e5 */
  font-size: 24px;
}

.buyer-history-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #0f172a;
}

.buyer-history-capsule {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.buyer-history-scope-badge,
.glacier-history-badge.is-readonly {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 9999px;
}

.buyer-history-close-btn {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.buyer-history-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* --- Category Tabs Bar --- */
.buyer-history-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.buyer-history-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.buyer-history-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.buyer-history-tab:hover {
  color: #1e293b;
}

.buyer-history-tab.is-active {
  color: #4f46e5;
  border-bottom-color: #4f46e5;
  font-weight: 600;
}

.glacier-tab-count {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #64748b;
}

.buyer-history-tab.is-active .glacier-tab-count {
  background: #e0e7ff;
  color: #4338ca;
}

.buyer-history-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.buyer-history-action-btn {
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.buyer-history-action-btn:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

/* --- Feed Body --- */
.buyer-history-feed-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: #f8fafc;
}

.buyer-history-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Accordion Event Card --- */
.glacier-event-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.glacier-event-card:hover {
  border-color: #cbd5e1;
}

.glacier-event-card.is-expanded {
  border-color: #cbd5e1;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.glacier-event-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: #ffffff;
  transition: background 0.15s ease;
}

.glacier-event-header:hover {
  background: #fcfdfe;
}

.glacier-event-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.glacier-event-icon-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.glacier-event-icon-badge.cat-buyer_record { background: #e0f2fe; color: #0284c7; }
.glacier-event-icon-badge.cat-responsibility { background: #fef3c7; color: #d97706; }
.glacier-event-icon-badge.cat-sharing_ownership { background: #ede9fe; color: #7c3aed; }
.glacier-event-icon-badge.cat-lifecycle { background: #fce7f3; color: #db2777; }

.glacier-event-icon-badge .material-symbols-outlined {
  font-size: 16px;
}

.glacier-event-title-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.glacier-event-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.glacier-event-subtitle {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 1px;
}

.glacier-event-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.glacier-event-actor {
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.glacier-event-time {
  font-size: 11.5px;
  color: #94a3b8;
}

.glacier-event-chevron {
  color: #94a3b8;
  font-size: 18px;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.glacier-event-card.is-expanded .glacier-event-chevron {
  transform: rotate(180deg);
}

/* --- Accordion Card Body (Diffs) --- */
.glacier-event-body {
  display: none;
  padding: 12px 16px 14px 16px;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
}

.glacier-event-card.is-expanded .glacier-event-body {
  display: block;
}

.glacier-diff-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.glacier-diff-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.glacier-diff-attr {
  width: 140px;
  flex-shrink: 0;
  font-weight: 600;
  color: #475569;
}

.glacier-diff-old {
  flex: 1;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 6px 10px;
  border-radius: 6px;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.glacier-diff-old.is-empty {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
  font-style: italic;
}

.glacier-diff-arrow {
  color: #94a3b8;
  font-size: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.glacier-diff-new {
  flex: 1;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 6px 10px;
  border-radius: 6px;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.glacier-diff-new.is-empty {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
  font-style: italic;
}

.glacier-event-metadata {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.glacier-meta-tag {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
}

/* --- Pagination & Loading --- */
.glacier-pagination-footer {
  padding: 12px 0 4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.glacier-load-more-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.glacier-load-more-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

/* --- Empty, Loading & Error States --- */
.glacier-empty-state, .glacier-error-state {
  text-align: center;
  padding: 48px 20px;
}

.glacier-state-icon {
  font-size: 40px;
  color: #94a3b8;
  margin-bottom: 12px;
}

.glacier-state-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 6px 0;
}

.glacier-state-desc {
  font-size: 13px;
  color: #64748b;
  margin: 0 auto;
  max-width: 320px;
}

.glacier-skeleton-card {
  height: 52px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: glacier-shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes glacier-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Access Request & Pending Dialogs --- */
.glacier-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.glacier-dialog-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.glacier-dialog-card {
  background: #ffffff;
  width: 480px;
  max-width: 90vw;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.glacier-dialog-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
}

.glacier-dialog-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #0f172a;
}

.glacier-dialog-body {
  padding: 20px;
}

.glacier-dialog-text {
  font-size: 13.5px;
  color: #475569;
  line-height: 1.5;
  margin: 0 0 14px 0;
}

.glacier-dialog-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  box-sizing: border-box;
  resize: vertical;
}

.glacier-dialog-textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.glacier-dialog-footer {
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --- Responsive Layout Fallback --- */
@media (max-width: 600px) {
  .glacier-diff-row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .glacier-diff-attr {
    width: auto;
  }
  .glacier-diff-arrow {
    transform: rotate(90deg);
    align-self: center;
  }
}
