/* =========================
   MODAL (legacy – zachowane na przyszłość)
   ========================= */

.price-history-container {
  display: inline-block;
  margin-top: 15%;
}

.price-history-open.button {
  cursor: pointer;
  padding: 8px 14px;
  font-size: 14px;
}

body.price-history-modal-open {
  overflow: hidden;
}

.price-history-modal {
  display: none;
  position: fixed;
  z-index: 99999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  padding: 10%;
  box-sizing: border-box;
}

.price-history-modal-inner {
  background: #ffffff;
  border-radius: 6px;
  width: 100%;
  max-width: 900px;
  max-height: 80vh;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  padding: 18px;
  position: relative;
  box-sizing: border-box;
  animation: ph-fade-in .12s ease-in;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.price-history-close {
  position: absolute;
  right: 10px;
  top: 8px;
  background: transparent;
  border: 0;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: #333;
}

/* =========================
   ACCORDION
   ========================= */

.price-history-accordion {
  border-radius: 6px;
  margin: 16px 0;
  background: #fff;
  border: none !important;
  max-width: 100%;
  min-width: 0;
  overflow: visible; /* nie ukrywaj scrolla dzieci */
}

.price-history-accordion-toggle {
  width: 100%;
  text-align: left;
  background: transparent !important;
  border: none;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.2s ease;
}

.price-history-accordion-toggle:hover {
  background: transparent !important;
}

.price-history-accordion-toggle .ph-caret {
  margin-left: 8px;
  font-size: 12px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.price-history-accordion.open .ph-caret {
  transform: rotate(180deg);
}

.price-history-accordion-panel {
  background: #fff;
  padding: 0px !important;
  border-top: 1px solid #e0e0e0;
  min-width: 0;
  overflow: visible; /* nie ukrywaj scrolla dzieci */
}

/* =========================
   LOADER / KOMUNIKATY
   ========================= */

.price-history-loader {
  padding: 12px 0;
  color: #666;
  font-style: italic;
  text-align: center;
}

.price-history-error {
  color: #d32f2f;
  padding: 10px 12px;
  background: #ffebee;
  border-radius: 4px;
  margin: 8px 0;
  text-align: center;
}

.price-history-no-records {
  color: #555;
  padding: 10px 0;
  font-style: italic;
  text-align: center;
}

/* =========================
   TABELA – LOKALNY SCROLL
   ========================= */

/* Kontener zewnętrzny – bez scrolla */
.price-history-accordion .price-history-content {
  margin-top: 8px;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  overflow: visible; /* scroll jest niżej, w .price-history-scroll */
}

/* WRAPPER SCROLLA – TYLKO TEN MA overflow-x: auto */
.price-history-accordion .price-history-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;           /* POZIOMY SCROLL TUTAJ */
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

/* Tabela – szeroka, żeby wymusić scroll */
.price-history-accordion .price-history-table {
  width: 100%;
  min-width: 840px;           /* podniesione, żeby na pewno przekroczyć mobile */
  border-collapse: collapse;
  margin: 0;
  font-size: 14px;
  background: #fff;
  table-layout: fixed;        /* zapobiega rozpychaniu przez długie ciągi */
}

/* Łamanie długich treści */
.price-history-accordion .price-history-table th,
.price-history-accordion .price-history-table td {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  text-align: left;
  padding: 10px 12px;
  font-size: 14px;
  border-left: 1px solid #f0f0f0;
  border-right: 1px solid #f0f0f0;
}

/* Nagłówki sticky */
.price-history-accordion .price-history-table thead th {
  background: #f7f7f7;
  border-bottom: 2px solid #ddd;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
  color: #333;
}

/* Komórki */
.price-history-accordion .price-history-table tbody td {
  border-bottom: 1px solid #eee;
  vertical-align: top;
  color: #333;
}

/* Alternatywne wiersze + hover */
.price-history-accordion .price-history-table tbody tr:nth-child(even) {
  background: #fafafa;
}
.price-history-accordion .price-history-table tbody tr:hover {
  background: #f0f0f0;
}

.price-history-accordion .price-history-table tbody td small {
  color: #777;
  font-size: 12px;
}

/* =========================
   TWARDY DEFENSYWNY RESET
   ========================= */

/* Zapewnia poprawne kurczenie w layoutach flex/grid */
.price-history-accordion,
.price-history-accordion *,
.price-history-accordion *::before,
.price-history-accordion *::after {
  box-sizing: border-box;
}

/* Dopuszcza kurczenie w grid/flex */
.price-history-accordion,
.price-history-accordion .price-history-content,
.price-history-accordion .price-history-scroll {
  min-width: 0 !important;
}

/* =========================
   RESPONSYWNOŚĆ
   ========================= */

@media (max-width: 640px) {
  /* zmniejsz padding i czcionkę */
  .price-history-accordion .price-history-table {
    font-size: 13px;
  }
  .price-history-accordion .price-history-table th,
  .price-history-accordion .price-history-table td {
    padding: 8px 10px;
  }

  /* przydział szerokości – krótkie kolumny węższe, długie skracane */
  .price-history-accordion .price-history-table th:nth-child(1),
  .price-history-accordion .price-history-table td:nth-child(1) { /* Data */
    width: 80px !important;
  }
  .price-history-accordion .price-history-table th:nth-child(2),
  .price-history-accordion .price-history-table td:nth-child(2) { /* Cena */
    width: 100px !important;
    white-space: nowrap;             /* cena zwykle w 1 linii */
  }
  .price-history-accordion .price-history-table th:nth-child(3),
  .price-history-accordion .price-history-table td:nth-child(3) { /* Zmiana */
    width: 80px !important;
    white-space: nowrap;
  }
  .price-history-accordion .price-history-table th:nth-child(4),
  .price-history-accordion .price-history-table td:nth-child(4) { /* Uwagi/Opis */
    width: auto;
  }

  /* agresywniejszy clamp dla długich opisów na mobile (1 linia) */
  .price-history-accordion .price-history-table td:nth-child(4) .ph-cell {
    -webkit-line-clamp: 1;
  }
}