/* ==========================================================================
   06-tables.css — Tabulky (komponentové varianty)
   seoprakticky.cz
   ==========================================================================
   Komponentové tabulky přepisující globální styl z 02-base.css.
   Globální <table> fallback zůstává v 02-base.css.

   1. .pk-table-simple  — jednoduchá tabulka bez záhlaví
   2. .pk-table-head    — tabulka se záhlavím (+ varianta --scroll pro 4+ sloupce)
   3. .pk-compare       — srovnávací tabulka (2 služby)
   ========================================================================== */


/* ══════════════════════════════════════════════════════════════════════════
   1. PK-TABLE-SIMPLE — Jednoduchá tabulka bez záhlaví
   ══════════════════════════════════════════════════════════════════════════ */

.pk-table-simple {
  --cell:   #FFFFFF;
  --alt:    #F8F9FA;
  --hover:  #F1F3F5;
  --b:      #E5E7EB;
  --text:   #111827;
  --muted:  #374151;

  width: 100%;
  max-width: var(--max-width-text);
  margin: 0 auto;
  border: 1px solid var(--b);
  border-radius: 6px;
  overflow: hidden;
  background: var(--cell);
}

.pk-table-simple table {
  width: 100%;
  margin: 0 auto;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

.pk-table-simple td {
  padding: 14px 16px;
  vertical-align: top;
  color: var(--text);
  background: var(--cell);
  border-top: 1px solid var(--b);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.pk-table-simple tr:first-child td           { border-top: 0; }
.pk-table-simple td + td                     { border-left: 1px solid var(--b); }
.pk-table-simple tr:nth-child(even) td       { background: var(--alt); }
.pk-table-simple tr:hover td                 { background: var(--hover); }

.pk-table-simple td:first-child {
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

/* 3+ sloupců → fixed layout */
@supports selector(.pk-table-simple table:has(td:nth-child(3))) {
  .pk-table-simple table:has(td:nth-child(3)) {
    table-layout: fixed;
  }
  .pk-table-simple table:has(td:nth-child(3)) td:first-child {
    white-space: normal;
    width: 32%;
  }
}

@media (max-width: 720px) {
  .pk-table-simple { max-width: 100%; }
  .pk-table-simple table { width: 100%; font-size: 15px; table-layout: auto; }
  .pk-table-simple td:first-child { white-space: normal; }

  @supports selector(.pk-table-simple table:has(td:nth-child(3))) {
    .pk-table-simple table:has(td:nth-child(3))         { table-layout: auto; }
    .pk-table-simple:has(table td:nth-child(3))         { overflow: visible; }

    .pk-table-simple:has(table td:nth-child(3)) tbody,
    .pk-table-simple:has(table td:nth-child(3)) tr      { display: block; width: 100%; }

    .pk-table-simple:has(table td:nth-child(3)) tr      { padding: 12px 14px; border: 0; }

    .pk-table-simple:has(table td:nth-child(3)) tr:nth-child(even) { background: var(--alt); }
    .pk-table-simple:has(table td:nth-child(3)) tr:nth-child(odd)  { background: var(--cell); }

    .pk-table-simple:has(table td:nth-child(3)) td {
      display: block;
      width: 100%;
      padding: 0;
      border: 0 !important;
      background: transparent;
    }

    .pk-table-simple:has(table td:nth-child(3)) td:first-child    { font-weight: 700; color: var(--muted); margin: 0 0 6px; }
    .pk-table-simple:has(table td:nth-child(3)) td:not(:first-child) { margin-top: 4px; }
    .pk-table-simple:has(table td:nth-child(3)) tr:hover td        { background: transparent; }
  }
}


/* ══════════════════════════════════════════════════════════════════════════
   2. PK-TABLE-HEAD — Tabulka se záhlavím
   ══════════════════════════════════════════════════════════════════════════ */

.pk-table-head {
  --cell:   #ffffff;
  --alt:    #F8F9FA;
  --hover:  #F1F3F5;
  --b:      #E5E7EB;
  --text:   #111827;
  --muted:  #374151;
  --head:   #E3E8EE;
  --head2:  #D6DDE6;

  width: 100% !important;
  max-width: var(--max-width-text);
  margin: 0 auto !important;
  text-align: left !important;
  box-sizing: border-box;

  border: 1px solid var(--b) !important;
  border-radius: 6px !important;
  background: var(--cell) !important;
  box-shadow: 0 0 0 1px var(--b) inset !important;
  overflow: hidden !important;
}

.pk-table-head table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  table-layout: auto !important;
  background: transparent !important;
  font: inherit !important;
  color: inherit !important;
}

.pk-table-head th,
.pk-table-head td {
  font: inherit !important;
  color: var(--text) !important;
}

/* Záhlaví */
.pk-table-head thead th {
  padding: 14px 16px !important;
  font-weight: 700 !important;
  background: linear-gradient(180deg, #E8EDF3 0%, #DDE5EE 100%) !important;
  font-size: 1.05em !important;
  border-bottom: 2px solid var(--head2) !important;
  vertical-align: top !important;
  position: relative;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.pk-table-head thead th::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.75);
}

.pk-table-head thead th + th { border-left: 0 !important; }

/* Tělo */
.pk-table-head td {
  padding: 14px 16px !important;
  vertical-align: top !important;
  background: var(--cell) !important;
  border-top: 1px solid var(--b) !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.pk-table-head tbody tr:first-child td    { border-top: 0 !important; }
.pk-table-head td + td                    { border-left: 0 !important; }
.pk-table-head tbody tr:nth-child(even) td { background: #FBFCFD !important; }
.pk-table-head tbody tr:hover td          { background: var(--hover) !important; }

/* 1. sloupec */
.pk-table-head tbody td:first-child {
  font-weight: 600 !important;
  color: var(--muted) !important;
  background: #F3F5F8 !important;
  border-right: 0 !important;
  box-shadow: inset -1px 0 0 rgba(17, 24, 39, 0.08);
}

.pk-table-head tbody tr:nth-child(even) td:first-child { background: #F3F5F8 !important; }
.pk-table-head tbody tr:hover td:first-child            { background: #EEF2F6 !important; }

/* Mobil — standard */
@media (max-width: 720px) {
  .pk-table-head { max-width: 100%; overflow: hidden !important; }
  .pk-table-head table { table-layout: fixed !important; }
  .pk-table-head thead th,
  .pk-table-head td { padding: 10px !important; white-space: normal !important; min-width: 0; }
}

/* Mobil — scroll varianta (4+ sloupců): přidejte třídu .pk-table-head--scroll */
@media (max-width: 720px) {
  .pk-table-head.pk-table-head--scroll {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable both-edges;
    touch-action: pan-x;
    position: relative;
    border-radius: 6px !important;
    border: 1px solid var(--b) !important;
    box-shadow: 0 0 0 1px var(--b) inset !important;
    background: var(--cell) !important;
  }

  .pk-table-head.pk-table-head--scroll table {
    width: 100% !important;
    min-width: 760px;
    table-layout: fixed !important;
  }

  .pk-table-head.pk-table-head--scroll thead th,
  .pk-table-head.pk-table-head--scroll td {
    min-width: 0 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
    padding: 10px 12px !important;
    vertical-align: top !important;
  }

  .pk-table-head.pk-table-head--scroll thead th:first-child,
  .pk-table-head.pk-table-head--scroll tbody td:first-child {
    width: 140px;
    max-width: 140px;
  }

  .pk-table-head.pk-table-head--scroll tbody td:first-child {
    overflow-wrap: normal;
    word-break: normal;
  }

  /* Gradient hint pro scroll */
  .pk-table-head.pk-table-head--scroll::after {
    content: "";
    position: absolute;
    top: 0; right: 0;
    width: 40px; height: 100%;
    pointer-events: none;
    background: linear-gradient(to left, rgba(229, 231, 235, 1), rgba(229, 231, 235, 0));
  }

  .pk-table-head.pk-table-head--scroll::before {
    content: "Posuňte tabulku →";
    position: absolute;
    right: 10px;
    bottom: 10px;
    pointer-events: none;
    font-size: 12px;
    line-height: 1;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--b);
    border-radius: var(--radius-full);
    padding: 7px 10px;
    box-shadow: 0 2px 10px rgba(17, 24, 39, 0.06);
  }

  .pk-table-head.pk-table-head--scroll::-webkit-scrollbar { height: 10px; }
  .pk-table-head.pk-table-head--scroll::-webkit-scrollbar-track { background: var(--head); }
  .pk-table-head.pk-table-head--scroll::-webkit-scrollbar-thumb {
    background: #C9D2DC;
    border-radius: var(--radius-full);
    border: 2px solid var(--head);
  }
  .pk-table-head.pk-table-head--scroll {
    scrollbar-width: thin;
    scrollbar-color: #C9D2DC var(--head);
  }
}

@media (max-width: 380px) {
  .pk-table-head.pk-table-head--scroll thead th:first-child,
  .pk-table-head.pk-table-head--scroll tbody td:first-child { width: 120px; max-width: 120px; }
}


/* ══════════════════════════════════════════════════════════════════════════
   3. PK-COMPARE — Srovnávací tabulka (2 služby)
   ══════════════════════════════════════════════════════════════════════════ */

.pk-compare {
  --plus:  #15803d;
  --minus: #b91c1c;

  margin: 22px 0;
  font-family: inherit;
  color: #0f172a;
}

.pk-compare__table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-none);
  background: var(--color-bg);
  overflow: hidden;
}

@media (max-width: 860px) { .pk-compare__table { grid-template-columns: 1fr; } }

.pk-compare__col { padding: 18px 18px 16px; }
.pk-compare__col + .pk-compare__col { border-left: 1px solid var(--color-border); }

@media (max-width: 860px) {
  .pk-compare__col + .pk-compare__col { border-left: 0; border-top: 1px solid var(--color-border); }
}

.pk-compare__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.pk-compare__title { margin: 0; color: inherit; }

.pk-compare__tag {
  padding: 6px 10px;
  border-radius: var(--radius-none);
  border: 1px solid var(--color-bg-soft);
  background: #fbf8c7;
  color: #0f172a;
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  font-family: inherit;
}

.pk-compare__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.pk-compare__col .pk-compare__list + .pk-compare__list { margin-top: 14px; }

.pk-compare__item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pk-compare__text {
  color: #475569;
  font-size: var(--text-base);
  line-height: 1.4;
  background-color: rgba(0, 0, 0, 0);
  font-family: inherit;
}

.pk-compare__icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 22px;
  line-height: 1;
  font-family: inherit;
}

.pk-compare__item--plus .pk-compare__icon {
  color: var(--plus);
  background: rgba(21, 128, 61, 0.08);
  border: 1.5px solid rgba(21, 128, 61, 0.25);
  transform: translateY(-1px);
}

.pk-compare__item--minus .pk-compare__icon {
  color: var(--minus);
  background: rgba(185, 28, 28, 0.08);
  border: 1.5px solid rgba(185, 28, 28, 0.25);
  transform: translateY(-1.5px);
}
