/* Tematy – ten sam układ i kolorystyka co strona kręgów (index), mniej zaokrągleń */

/* Ograniczenie szerokości – brak poziomego przewijania na telefonie */
body.tematy-body,
body.tematy-admin-body {
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
}
main.tematy-main,
main.tematy-admin-main {
  min-width: 0;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}
/* Safe area dla wycięć (notch, iPhone) */
@supports (padding: max(0px)) {
  .tematy-body main.tematy-main {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
}

/* Listwa górna – tło bg-gray-700, litery na biało (nadpis z innych CSS) */
body.tematy-body > header,
body.tematy-admin-body > header {
  color: #fff;
}
body.tematy-body > header a,
body.tematy-admin-body > header a {
  color: #fff !important;
}
body.tematy-body > header a:hover,
body.tematy-admin-body > header a:hover {
  color: #fff !important;
}

/* Kolory i cienie jak na stronie głównej kregi */
.tematy-page,
.tematy-grid {
  --tematy-panel: #ffffff;
  --tematy-line: #e5e7eb;
  --tematy-text: #1f2937;
  --tematy-muted: #6b7280;
  --tematy-accent: #4285F4;
  --tematy-accent-hover: #3367D6;
  --tematy-radius: 4px;
  --tematy-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.1);
  --tematy-shadow-hover: 0 4px 8px rgba(0,0,0,0.15), 0 8px 16px rgba(0,0,0,0.15);
}

/* ---------- Wyszukiwarka (w nagłówku sekcji) – na telefonie pełna szerokość, przycisk pod spodem ---------- */
.tematy-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  min-width: 0;
}
@media (min-width: 640px) {
  .tematy-toolbar {
    flex-wrap: nowrap;
  }
  .tematy-toolbar .tematy-search-wrap {
    margin-right: auto;
  }
}
.tematy-search-wrap {
  min-width: 0;
  flex: 1 1 auto;
}
@media (min-width: 480px) {
  .tematy-search-wrap {
    max-width: 14rem;
  }
}
.tematy-search-wrap input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.tematy-btn-add-own {
  flex: 0 0 auto;
  min-width: 0;
}
@media (max-width: 479px) {
  .tematy-btn-add-own {
    width: 100%;
    white-space: normal;
    text-align: center;
    min-height: 44px;
  }
}

/* Przycisk Dodaj swój temat – zielony, po prawej, zawsze widoczny */
.tematy-btn-add-own {
  background: #16a34a;
  color: #fff;
  border: none;
  cursor: pointer;
}
.tematy-btn-add-own:hover {
  background: #15803d;
  color: #fff;
}
/* Odstęp 2 znaki przed przyciskiem zielonym (gdy w jednej linii) */
@media (min-width: 640px) {
  .tematy-toolbar-hint {
    margin-right: 2ch;
  }
}

/* ---------- Lista kafelek: 1 kolumna mobile, 2 tablet, 3 w linii desktop ---------- */
.tematy-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .tematy-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 1024px) {
  .tematy-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Kafelek: Zobacz | Nr·Data + Autor, potem Temat (pogrubiony, 2 linie), Opis (2 linie), Strona autora ---------- */
.tematy-card {
  min-width: 0;
  transition: box-shadow 0.2s ease;
}
@media (hover: hover) {
  .tematy-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15), 0 8px 16px rgba(0,0,0,0.15);
  }
}
.tematy-card .line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  overflow-wrap: break-word;
}
.tematy-card-temat {
  font-weight: 700;
  color: var(--tematy-text);
  line-height: 1.35;
}
.tematy-card-opis {
  line-height: 1.4;
}
.tematy-card-footer {
  line-height: 1.4;
}
.tematy-card-author-link {
  color: var(--tematy-accent);
  text-decoration: none;
}
.tematy-card-author-link:hover {
  text-decoration: underline;
}
.tematy-btn-zobacz {
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.tematy-grid .tematy-empty {
  grid-column: 1 / -1;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--tematy-muted);
  font-size: 0.9375rem;
}

/* ---------- Paginacja – zawsze: Poprzednia strona | Strona X z Y | Następna strona ---------- */
.tematy-pagination {
  margin-top: 1.5rem;
  padding: 0.5rem 0;
}
.tematy-pagination-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
}
.tematy-pag-btn {
  padding: 0.5rem 1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--tematy-radius);
  font-size: 0.875rem;
  font-weight: 700;
  box-sizing: border-box;
  background: #e5e7eb;
  color: #374151;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.tematy-pagination a.tematy-pag-btn {
  background: #e5e7eb;
  color: #374151;
  font-weight: 700;
}
.tematy-pagination a.tematy-pag-btn:hover {
  background: #d1d5db;
  color: #1f2937;
}
.tematy-pag-btn:hover {
  background: #d1d5db;
  color: #1f2937;
}
.tematy-pag-btn.tematy-pag-disabled {
  background: #e5e7eb;
  color: #6b7280;
  font-weight: 400;
  cursor: not-allowed;
  pointer-events: none;
}
.tematy-pag-btn.tematy-pag-disabled:hover {
  background: #e5e7eb;
  color: #6b7280;
  font-weight: 400;
}
.tematy-pag-current {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--tematy-text);
}

/* Nagłówek strony – łamanie długich tytułów na telefonie */
.hero-section .hero-title-bold {
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.hero-subtitle {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Mobile – dopasowanie do wąskich ekranów (320px+) */
@media (max-width: 479px) {
  .tematy-body section.material-card {
    padding: 0.75rem 1rem;
  }
  .tematy-toolbar .tematy-search-wrap {
    max-width: 100%;
  }
  .tematy-card {
    padding: 0.75rem 1rem;
  }
  .tematy-pagination a,
  .tematy-pagination span {
    min-width: 40px;
    min-height: 40px;
    padding: 0.4rem 0.5rem;
    font-size: 0.8125rem;
  }
}

/* ---------- Modal ZOBACZ i modal formularza Dodaj temat ---------- */
.tematy-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tematy-modal.hidden {
  display: none !important;
}
.tematy-modal-inner {
  background: #fff;
  border-radius: var(--tematy-radius);
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15), 0 8px 16px rgba(0,0,0,0.15);
  margin: auto;
}
@media (min-width: 640px) {
  .tematy-modal-inner {
    padding: 1.5rem 2rem;
  }
}
.tematy-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.tematy-modal-meta {
  font-size: 0.8125rem;
  color: var(--tematy-muted);
}
.tematy-modal-close {
  flex-shrink: 0;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tematy-muted);
  background: transparent;
  border: none;
  border-radius: var(--tematy-radius);
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.tematy-modal-close:hover {
  background: #f3f4f6;
  color: var(--tematy-text);
}
.tematy-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--tematy-text);
  margin-bottom: 1rem;
  line-height: 1.3;
}
@media (min-width: 640px) {
  .tematy-modal-title {
    font-size: 1.375rem;
  }
}
.tematy-modal-body {
  font-size: 0.9375rem;
  color: #374151;
  line-height: 1.6;
  white-space: pre-wrap;
  margin-bottom: 1.25rem;
}
.tematy-modal-author {
  font-size: 0.875rem;
  color: var(--tematy-muted);
  line-height: 1.5;
}
.tematy-modal-link-wrap {
  display: block;
  margin-top: 0.35rem;
}
/* Link „odwiedź stronę” w modalu – wyraźnie niebieski (modal może być poza .tematy-grid) */
.tematy-modal .tematy-modal-author-link {
  color: #2563eb;
  text-decoration: none;
  word-break: break-all;
}
.tematy-modal .tematy-modal-author-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}
.tematy-modal-author a {
  color: var(--tematy-accent);
  text-decoration: none;
}
.tematy-modal-author a:hover {
  text-decoration: underline;
}

/* ---------- Admin tematów – formularz (wyrównane pola, przyciski bez przepełnienia) ---------- */
.tematy-admin-form .tematy-admin-input {
  max-width: 100%;
}
.tematy-admin-btn-add,
.tematy-admin-btn-cancel {
  min-height: 38px;
}

/* Przyciski w tabeli: Edytuj niebieski, Usuń czerwony z białym napisem */
.tematy-admin-btn-edit {
  background: #2563eb !important;
  color: #fff !important;
  border: none !important;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tematy-admin-btn-edit:hover {
  background: #1d4ed8 !important;
  color: #fff !important;
}
.tematy-admin-btn-delete {
  background: #dc2626 !important;
  color: #fff !important;
  border: none !important;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tematy-admin-btn-delete:hover {
  background: #b91c1c !important;
  color: #fff !important;
}

/* ---------- Admin tematów – responsywność ---------- */
#adminForm,
#adminList {
  max-width: 100%;
  min-width: 0;
}
#adminList .overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  margin-left: -0.25rem;
  margin-right: -0.25rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}
@media (max-width: 639px) {
  #adminList table {
    font-size: 0.8125rem;
  }
  #adminList th,
  #adminList td {
    padding: 0.35rem 0.25rem;
  }
}
