/* Шаблоны документов — каталог и страница документа */

.kb-hero--templates .page-title--templates {
  font-size: clamp(26px, 4vw, 41px);
  margin-bottom: 10px;
}

.templates-hero__category {
  margin: 0 0 14px;
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-accent);
}

.templates-hero__doc-title {
  margin: 0 0 14px;
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--color-heading);
}


@media (max-width: 992px) {
  .kb-hero--templates .page-title--templates {
    font-size: 31px;
  }

  .templates-hero__doc-title {
    font-size: 24px;
  }

  .templates-hero__doc-title--page {
    font-size: 21px;
  }
}

@media (max-width: 640px) {
  .kb-hero--templates .page-title--templates {
    font-size: 26px;
  }

  .templates-hero__category {
    font-size: 17px;
  }

  .templates-hero__doc-title {
    font-size: 21px;
  }
}

.templates-section {
  padding-bottom: 96px;
  scroll-margin-top: calc(var(--header-height, 72px) + 12px);
}

.templates-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.templates-toolbar__search {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  margin: 0;
}

.templates-toolbar .search-box {
  max-width: none;
  margin: 0;
  width: 100%;
}

.templates-toolbar .search-input {
  height: 40px;
  padding: 0 16px 0 40px;
  font-size: 14px;
  line-height: 1.2;
  border-radius: 10px;
  box-shadow: none;
}

.templates-toolbar .search-icon {
  left: 14px;
  width: 18px;
  height: 18px;
}

.templates-view-toggle {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  height: 40px;
  padding: 4px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-white);
  gap: 4px;
  box-sizing: border-box;
}

.templates-view-toggle__btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.templates-view-toggle__btn:hover {
  color: var(--color-heading);
}

.templates-view-toggle__btn.is-active {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.templates-grid {
  --template-card-tag-row: 24px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.templates-grid--list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.templates-grid:not(.templates-grid--list) .template-card {
  min-height: 196px;
}

.template-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 16px 16px 14px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 12px rgba(17, 24, 39, 0.04);
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

.template-card[hidden] {
  display: none !important;
}

.templates-grid--list .template-card {
  flex-direction: row;
  align-items: center;
  gap: 12px 16px;
  min-height: 0;
  padding: 12px 16px;
}

.templates-grid--list .template-card:hover {
  transform: none;
}

.template-card:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--color-accent-rgb), 0.28);
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}

.template-card__top {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  height: var(--template-card-tag-row);
  max-height: var(--template-card-tag-row);
  margin-bottom: 10px;
  overflow: hidden;
}

.templates-grid--list .template-card__top,
.templates-grid--list .template-card__desc {
  display: none;
}

.template-card__badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.template-card__badge--free {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.template-card__badge--paid {
  background: rgba(var(--color-accent-rgb), 0.12);
  color: var(--color-accent);
}

.template-card__tags {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  width: 100%;
  min-width: 0;
  max-height: var(--template-card-tag-row);
  overflow: hidden;
}

.template-card__tags li {
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 1.35;
  color: var(--color-text-muted);
  padding: 3px 8px;
  border-radius: 999px;
  background: #F3F4F6;
  white-space: nowrap;
}

.template-card__tags li[hidden] {
  display: none !important;
}

.template-card__title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--color-heading);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.templates-grid--list .template-card__title {
  flex: 1 1 auto;
  margin: 0;
  -webkit-line-clamp: 1;
  min-width: 0;
}

.template-card__desc {
  margin: 0;
  flex: 1 1 auto;
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.template-card__category {
  display: none;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.templates-grid--list .template-card__category {
  display: block;
  min-width: 120px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-card__link {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  flex-shrink: 0;
}

.templates-grid--list .template-card__link {
  margin-top: 0;
  white-space: nowrap;
  font-size: 0;
}

.templates-grid--list .template-card__link::before {
  content: 'Открыть →';
  font-size: 13px;
  font-weight: 600;
}

.templates-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
}

.templates-pagination__item {
  appearance: none;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-white);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-heading);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.templates-pagination__item:hover:not(:disabled):not(.is-current) {
  border-color: rgba(var(--color-accent-rgb), 0.35);
  color: var(--color-accent);
}

.templates-pagination__item.is-current {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  cursor: default;
}

.templates-pagination__item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.templates-pagination__nav {
  min-width: auto;
  padding: 0 14px;
}

.template-card:hover .template-card__link {
  color: var(--color-accent-hover);
}

.templates-search-empty {
  margin: 24px 0 0;
  text-align: center;
  color: var(--color-text-muted);
}

.templates-empty {
  padding-bottom: 96px;
}

.templates-empty__card {
  max-width: 720px;
  margin: 0 auto;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(17, 24, 39, 0.06);
}

.templates-empty__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: var(--color-accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--color-accent);
}

.templates-empty__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: 12px;
}

.templates-empty__text {
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
}

.templates-empty__text a,
.templates-empty__cta a {
  color: var(--color-accent);
  font-weight: 600;
}

.templates-empty__cta {
  margin-top: 12px;
  font-size: 15px;
}

/* ---- Страница документа ---- */

.kb-hero--document {
  padding-bottom: 28px;
}

.kb-hero-content--document-top {
  text-align: center;
  max-width: 900px;
  margin: 0 auto;
}

.kb-hero--document .kb-breadcrumb {
  justify-content: center;
}

.kb-hero--document .page-title--templates {
  margin-bottom: 22px;
}

.template-doc__header-body {
  text-align: left;
  max-width: 100%;
  margin-top: 0;
}

.templates-hero__doc-title--page {
  margin: 0 0 12px;
  font-size: 24px;
  line-height: 1.35;
  text-align: left;
}

.template-doc {
  padding-bottom: 96px;
}

.template-doc__lead {
  text-align: left;
  margin-bottom: 0;
  max-width: 820px;
}

.template-doc__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.template-doc__tags li {
  font-size: 12px;
  line-height: 1.35;
  padding: 5px 10px;
  border-radius: 999px;
  background: #F3F4F6;
  color: var(--color-text-muted);
}

.template-doc__stack {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.template-doc__checklist {
  width: 100%;
  box-sizing: border-box;
  padding: 24px 28px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: #F8FAFC;
}

.template-doc__checklist-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-heading);
}

.template-doc__checklist ul {
  margin: 0;
  padding-left: 20px;
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.6;
}

.template-doc__checklist li + li {
  margin-top: 10px;
}

.template-doc__preview-block {
  width: 100%;
}

.template-doc__preview-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-heading);
  text-align: left;
}

.template-preview {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-white);
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(17, 24, 39, 0.07);
}

.template-preview--full {
  border-color: rgba(var(--color-accent-rgb), 0.12);
}

.template-preview__body {
  position: relative;
}

.template-preview__body--scroll {
  max-height: min(75vh, 980px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.template-preview__content {
  padding: 0;
}

.template-preview__raw {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 32px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  tab-size: 4;
}

.template-preview__visible,
.template-preview__blur {
  padding: 32px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.template-preview--locked .template-preview__visible {
  padding-bottom: 12px;
}

.template-preview__locked {
  position: relative;
  max-height: 220px;
  overflow: hidden;
}

.template-preview__blur {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
  opacity: 0.85;
}

.template-preview__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px 20px 18px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.88) 45%,
    rgba(255, 255, 255, 0.98) 100%
  );
}

.template-preview__overlay-text {
  margin: 0;
  max-width: 420px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--color-heading);
}

.template-doc__actions {
  margin-top: 28px;
  text-align: left;
}

.template-doc__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.template-doc__btn--download,
.template-doc__btn--buy {
  background: var(--color-accent);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(var(--color-accent-rgb), 0.22);
}

.template-doc__btn--download:hover,
.template-doc__btn--buy:hover {
  background: var(--color-accent-hover);
  color: #FFFFFF;
  transform: translateY(-1px);
}

.template-doc__value {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.template-doc__consent {
  max-width: 520px;
}

@media (max-width: 1200px) {
  .templates-grid:not(.templates-grid--list) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 992px) {
  .templates-grid:not(.templates-grid--list) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .templates-toolbar {
    flex-wrap: wrap;
  }

  .templates-toolbar__search {
    flex: 1 1 100%;
  }

  .templates-view-toggle {
    margin-left: auto;
  }

  .templates-grid--list .template-card {
    flex-wrap: wrap;
  }

  .templates-grid--list .template-card__category {
    width: 100%;
    max-width: none;
    order: 2;
  }

}

@media (max-width: 640px) {
  .templates-grid:not(.templates-grid--list) {
    grid-template-columns: 1fr;
  }

  .templates-grid--list .template-card__link {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .template-card,
  .template-doc__btn {
    transition: none;
  }
}
