/* Panel - Podsumowanie i siatka udostępniania (/p/...)
   Wyjęte z panel-dashboard.css (etap C6). Ładowane w tej samej kolejności co wcześniej. */

/* Summary page */
.summary-page .summary-kpi-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-layout .panel {
  padding: 16px;
  margin-bottom: 0;
}

.summary-layout .dash-panel-head {
  margin-bottom: 10px;
}

.summary-layout .dash-panel-head h2 {
  font-size: 15px;
}

.summary-kpi-grid .dash-kpi-card-rich {
  min-height: 0;
  padding: 14px 16px;
  background: var(--panel);
  gap: 10px 12px;
}

.summary-kpi-grid .dash-kpi-card-budget {
  background: var(--panel);
}

.summary-kpi-grid .dash-kpi-icon {
  width: 40px;
  height: 40px;
}

.summary-kpi-grid .dash-kpi-icon img {
  width: 22px;
  height: 22px;
}

.summary-kpi-grid .dash-kpi-value {
  font-size: 19px;
}

.summary-kpi-grid .dash-donut-sm {
  width: 40px;
  height: 40px;
}

.summary-kpi-grid .dash-donut-sm span {
  font-size: 11px;
}

@media (max-width: 1240px) {
  .summary-page .summary-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.summary-layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 3fr) minmax(240px, 2fr);
  grid-template-areas:
    "bar donut sidebar"
    "quad quad quad"
    "schedule schedule schedule";
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

/* Udostępnianie projektu (widok /p/{token}) - kolejność i widoczność kafelków ustawia
   właściciel w modalu "Udostępnij projekt". Siatka ma 12 kolumn (podzielne przez 4, więc
   wiersz z 4 małymi kafelkami wypełnia całą szerokość, tak jak wiersz z wykresami powyżej).
   Każdy kafelek dostaje klasę .share-slot-N (N = pozycja wśród widocznych sekcji) - jego
   rozmiar zależy WYŁĄCZNIE od pozycji, nie od treści, więc przesunięcie np. "Pogody" na
   miejsce wykresu automatycznie robi z niej szerszy kafelek (i odwrotnie). Auto-placement
   (bez "dense") sam dopełnia siatkę - patrz komentarz przy każdym slocie dla matematyki. */
.share-layout-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(160px, auto)) minmax(260px, auto);
  grid-template-areas: none;
  grid-auto-rows: minmax(120px, auto);
  grid-auto-flow: row dense;
  align-items: stretch;
}

.share-slot {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
  height: auto;
}

.share-slot > .panel {
  flex: 1 1 auto;
  height: auto;
  min-height: 100%;
  margin-bottom: 0;
  min-width: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.share-layout-grid .share-slot-row-widgets > .panel,
.share-layout-grid .share-slot-row-charts > .panel,
.share-layout-grid .share-slot-row-side > .panel {
  height: auto;
  min-height: 100%;
}

.share-layout-grid .share-slot-row-side > .panel {
  justify-content: flex-start;
}

/* Wykresy i tabele w wąskich slotach nie mogą rozpychać siatki (min-width / 2-kolumnowy layout). */
.share-layout-grid .share-slot .summary-chart-layout {
  grid-template-columns: 1fr !important;
  min-width: 0;
}

.share-layout-grid .share-slot .summary-chart-plot-wrap,
.share-layout-grid .share-slot .summary-donut-area,
.share-layout-grid .share-slot .expenses-chart-plot-area {
  min-width: 0;
  max-width: 100%;
}

.share-layout-grid .share-slot .dash-table-wrap {
  overflow: auto;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.share-layout-grid .share-slot-section-recent_expenses {
  height: 100%;
  overflow: hidden;
}

.share-layout-grid .share-slot-section-recent_expenses > .panel {
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

.share-layout-grid .share-slot-section-recent_expenses .dash-table-wrap {
  max-height: 100%;
}

.share-layout-grid .share-slot-section-recent_expenses .dash-table {
  min-width: 480px;
}

.share-layout-grid .share-slot-section-recent_expenses .dash-table td,
.share-layout-grid .share-slot-section-recent_expenses .dash-table th {
  white-space: nowrap;
}

.share-layout-grid .share-slot .dash-receipts-grid {
  min-width: 0;
}

/* W wąskich kafelkach zadania układają się pionowo, tytuł może się zawinąć. */
.share-layout-grid .share-slot-col-2 .dash-task-list li,
.share-layout-grid .share-slot-col-3 .dash-task-list li {
  grid-template-columns: 1fr;
  gap: 4px;
  align-items: flex-start;
}

.share-layout-grid .share-slot-col-2 .dash-task-title,
.share-layout-grid .share-slot-col-3 .dash-task-title {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
}

.share-layout-grid .share-slot .dash-task-badges {
  flex-wrap: wrap;
}

.share-layout-grid .share-slot-section-upcoming_tasks .dash-task-list {
  max-height: 220px;
  overflow-y: auto;
}

.share-layout-grid .share-slot .summary-chart-legend {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Dokumenty w udostępnianym widoku - stała wysokość miniatury (max 4 szt.). */
.share-layout-grid .share-slot-section-recent_documents > .panel {
  max-height: none;
}

.share-layout-grid .share-slot-section-recent_documents .dash-receipts-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.share-layout-grid .share-slot-col-2.share-slot-section-recent_documents .dash-receipts-grid,
.share-layout-grid .share-slot-col-3.share-slot-section-recent_documents .dash-receipts-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.share-layout-grid .share-slot-section-recent_documents .dash-receipt-card {
  height: auto;
}

.share-layout-grid .share-slot-section-recent_documents .dash-receipt-thumb {
  height: 88px;
  min-height: 0;
  flex: none;
  background: #fff;
}

.share-layout-grid .share-slot-section-recent_documents .dash-receipt-thumb img,
.share-layout-grid .share-slot-section-recent_documents .dash-receipt-thumb object {
  object-fit: contain;
  background: #fff;
}

/* Wykresy zachowują sensowną wysokość mimo rowspan = 1. */
.share-layout-grid .share-slot-section-monthly_chart .summary-chart-plot-wrap {
  min-height: 220px;
}

.share-layout-grid .share-slot-section-category_chart .summary-donut-area,
.share-layout-grid .share-slot-section-category_chart .expenses-donut-wrap {
  min-height: 200px;
}

/* Pozycje kafelków (.share-slot-N) ustawiane inline w share-view.php (share_slot_grid_style).
   Klasy zostają tylko do ewentualnych hooków / responsywności. */

@media (max-width: 1300px) {
  .share-layout-grid {
    grid-template-columns: 1fr !important;
    grid-template-areas: none !important;
  }

  .share-layout-grid .share-slot {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
  }
}

.summary-bar-panel {
  grid-area: bar;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.summary-bar-panel .summary-chart-plot-wrap {
  flex: 1;
  min-height: 0;
}

.summary-bar-panel .summary-chart-empty,
.summary-donut-panel .summary-chart-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 140px;
  text-align: center;
  padding: 16px;
}

.summary-donut-panel {
  grid-area: donut;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.summary-donut-panel .summary-chart-layout {
  flex: 1;
  align-content: center;
}

.summary-donut-panel .dash-donut-lg {
  width: 128px;
  height: 128px;
}

.summary-donut-panel .dash-donut-center strong {
  font-size: 13px;
}

.summary-donut-panel .dash-donut-center small {
  font-size: 10px;
}

.summary-donut-panel .expenses-chart-legend li {
  margin-bottom: 4px;
}

.summary-sidebar {
  grid-area: sidebar;
  display: grid;
  gap: 12px;
  min-width: 0;
  align-content: stretch;
}

.summary-quad-row {
  grid-area: quad;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.summary-quad-row > * {
  min-width: 0;
  max-width: 100%;
}

.summary-schedule-panel {
  grid-area: schedule;
}

.summary-widget .dash-panel-head h2 {
  font-size: 1rem;
}

.summary-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin: 0 0 6px;
}

.summary-meta-row span {
  color: var(--muted);
  font-size: 0.92rem;
  flex: 1 1 6rem;
  min-width: 0;
}

.summary-meta-row strong {
  flex: 1 1 7rem;
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.summary-meta-row.is-over strong {
  color: #ef4444;
}

.summary-meta-row.is-warn strong {
  color: #f97316;
}

.summary-meta-row.is-good strong {
  color: var(--green);
}

.summary-status-body .dash-kpi-progress {
  margin-top: 10px;
}

.summary-deadline-note {
  margin: 0 0 10px;
  font-size: 0.9rem;
}

.summary-budget-rows {
  margin-bottom: 10px;
}

.summary-chart-plot-wrap {
  padding-top: 4px;
}

.summary-bar-chart-shell .summary-bar-chart {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  inset: 0;
}

.summary-bar-panel .expenses-chart-plot-main {
  min-height: 140px;
}

.expenses-chart-bar-labels {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.expenses-chart-bar-labels span {
  position: absolute;
  transform: translate(-50%, calc(-100% - 4px));
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
}

.summary-weather-current {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: 0;
}

.summary-weather-current > div {
  min-width: 0;
}

.summary-weather-icon {
  font-size: 2.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.summary-weather-temp {
  font-size: 1.6rem;
  line-height: 1.1;
}

.summary-weather-place {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.summary-weather-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--muted);
}

.summary-weather-forecast {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.summary-weather-forecast li {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 0.88rem;
  min-width: 0;
}

.summary-weather-forecast li small {
  text-align: right;
  font-size: 0.78rem;
}

.summary-weather-tip {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--blue) 8%, transparent);
  font-size: 0.82rem;
  color: var(--text);
}

.summary-schedule-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.summary-schedule-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 92%, var(--line));
  min-width: 0;
}

.summary-schedule-item strong {
  display: block;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 1300px) {
  .summary-layout {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    grid-template-areas:
      "bar donut"
      "sidebar sidebar"
      "quad quad"
      "schedule schedule";
  }

  .summary-quad-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1500px) {
  .summary-donut-panel .summary-chart-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .summary-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "bar"
      "donut"
      "sidebar"
      "quad"
      "schedule";
  }

  .summary-quad-row {
    grid-template-columns: 1fr;
  }

  .dash-task-list li {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .dash-task-title {
    white-space: normal;
  }

  .dash-task-badges {
    flex-wrap: wrap;
  }

  .summary-schedule-item {
    flex-wrap: wrap;
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  .summary-page .summary-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

