/* =========================================================
   Search page — cleaned (no duplicates) + mobile overflow fixes
   ========================================================= */

/* -------------------------
   Base / page
------------------------- */
main{
  background: #f5f6fa;
}

/* страховка от горизонтального скролла из-за мелких переполнений */
html, body{
  overflow-x: hidden;
}

img{
  max-width: 100%;
  height: auto;
}

.search-page{
  padding: 32px 16px;
  max-width: 1200px;
  margin: 0 auto;
  background: transparent;
}

.search-results{
  margin-top: 10px;
  background: transparent;
}

/* -------------------------
   Disabled form
------------------------- */
fieldset[disabled]{
  opacity: 0.6;
  pointer-events: none;
}

/* -------------------------
   Hero + search bar
------------------------- */
.search-hero{
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  margin-bottom: 18px;
  background: transparent;
  box-shadow: none;
}

.search-title{
  margin: 0;
  font-size: 2rem;
  color: #111;
  text-align: center;
}

.search-bar{
  width: 100%;
  max-width: 900px;
  box-sizing: border-box;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  margin: 0 auto;
}

.search-bar fieldset{
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
  background: transparent;
  box-shadow: none;
}

.search-input-wrap{
  display: flex;
  gap: 10px;
  align-items: center;
  position: relative;
}

.search-input{
  flex: 1;
  height: 68px;
  padding: 14px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
  background: #f9fafb;
  color: #111;
  min-width: 0; /* важно для мобилки */
}

.search-input-overlay{
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 4px;
  pointer-events: none;
  color: #6b7280;
  transition: opacity .15s ease;
}

.search-input-wrap.has-value .search-input-overlay{
  opacity: 0;
}

.search-input-overlay__line{
  font-size: 0.95rem;
  line-height: 1.2;
}

.search-input-overlay__label{
  color: #6b7280;
  font-weight: 500;
}

.search-input-overlay__example{
  color: inherit;
  font-weight: inherit;
  font-style: italic;
}

.search-input-overlay__example::after{
  content: "";
  display: inline-block;
  width: 1px;
  height: 1em;
  margin-left: 3px;
  background: #9ca3af;
  animation: search-caret-blink 1s steps(2, start) infinite;
}

@keyframes search-caret-blink{
  to { opacity: 0; }
}

.search-input:focus{
  border-color: #2f55d4;
  box-shadow: 0 0 0 3px rgba(47, 85, 212, 0.15);
}

.search-submit{
  height: 46px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  background: #2f55d4;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  flex: 1 1 auto;
  width: 100%;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.search-submit:hover{
  background: #2b4cc4;
  box-shadow: 0 10px 20px rgba(47, 85, 212, 0.25);
  transform: translateY(-1px);
}

.search-submit:active{
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(47, 85, 212, 0.2);
}

.search-submit-row{
  width: 100%;
  max-width: 900px;
  margin-top: 14px;
  display: flex;
  justify-content: stretch;
  gap: 12px;
  margin-left: auto;
  margin-right: auto;
}

.search-reset{
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}

.search-reset--inline{
  height: 42px;
  padding: 0 14px;
}

.search-reset:hover{
  border-color: #2f55d4;
}

/* -------------------------
   Categories (multi-select)
------------------------- */
.search-secondary-row{
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.multi-select{
  position: relative;
}

.select-btn{
  width: 100%;
  height: 42px;
  padding: 8px 12px;
  border: 1px solid #cfd4dc;
  border-radius: 999px;
  background: #fff;
  color: #111;
  cursor: pointer;
  text-align: left;
  font-size: 1em;
}

.select-dropdown{
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;

  background: #fff;
  color: #111;
  border: 1px solid #cfd4dc;
  border-radius: 12px;

  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;

  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.multi-select.active .select-dropdown{
  display: block;
}

.select-dropdown label{
  display: block;
  padding: 8px 12px;
  cursor: pointer;
  color: #111;
}

.select-dropdown label:hover{
  background: #f3f6ff;
}

.select-dropdown input[type="checkbox"]{
  margin-right: 8px;
}

/* -------------------------
   Controls row (sorting + toggle + buttons)
------------------------- */
.search-controls-row{
  width: 100%;
  max-width: 900px;
  margin-top: 12px;
  display: grid;
  grid-template-columns: max-content max-content minmax(0, 1fr) max-content;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  margin-right: auto;
}

.search-control-block{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sort-label{
  color: #111;
  font-weight: 600;
  white-space: nowrap;
}

.sort-control{
  justify-content: flex-end;
  width: 100%;
}

.sort-select{
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid #cfd4dc;
  background: #fff;
  color: #111;
  outline: none;
  font-weight: 600;
}

.sort-select:focus{
  border-color: #2f55d4;
  box-shadow: 0 0 0 3px rgba(47, 85, 212, 0.15);
}

.filters-toggle,
.filters-reset--inline{
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.filters-toggle:hover,
.filters-reset--inline:hover{
  border-color: #2f55d4;
}

/* -------------------------
   Only favorites toggle
------------------------- */
.only-favs-toggle{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  cursor: pointer;
}

.only-favs-text{
  color: #111;
  font-weight: 600;
  white-space: nowrap;
}

.only-favs-input{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.only-favs-switch{
  width: 42px;
  height: 24px;
  background: #d1d5db;
  border-radius: 999px;
  position: relative;
  transition: background .2s ease;
  border: 1px solid #cfd4dc;
  flex: 0 0 auto;
}

.only-favs-switch::after{
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transform: translateY(-50%);
  transition: left .2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.only-favs-input:checked + .only-favs-switch{
  background: #2f55d4;
  border-color: #2f55d4;
}

.only-favs-input:checked + .only-favs-switch::after{
  left: 21px;
}

.only-favs-toggle:has(.only-favs-input:focus-visible) .only-favs-switch{
  box-shadow: 0 0 0 3px rgba(47, 85, 212, 0.2);
}

/* -------------------------
   Advanced filters (collapsible)
------------------------- */
.advanced-filters{
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  box-sizing: border-box;
}

.advanced-section + .advanced-section{
  margin-top: 14px;
}

.advanced-title{
  font-weight: 700;
  margin-bottom: 8px;
  color: #111;
}

.filter-help-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 999px;
  background: #f1f3f5;
  color: #9aa3b2;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.advanced-title-help{
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tooltip-target.tooltip-wide::after{
  max-width: 480px;
  min-width: 360px;
}

.advanced-fields{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.advanced-fields--numbers{
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-field{
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.filter-label{
  font-weight: 600;
  color: #111;
}

.filter-input{
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111;
  outline: none;
  min-width: 0;
}

.filter-input:focus{
  border-color: #2f55d4;
  box-shadow: 0 0 0 3px rgba(47, 85, 212, 0.15);
}

.filter-textarea{
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}

.filter-range{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* -------------------------
   Results count + grid
------------------------- */
.search-stats-row{
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 15px;
  flex-wrap: nowrap;
  font-weight: 700;
  font-size: 1.05em;
  color: #111;
}

.search-stats-row .channels-count,
.search-stats-row .avg-cpm{
  font-weight: 700;
}

.channels-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  row-gap: 14px;
  align-items: stretch;
}

/* -------------------------
   Search results count
------------------------- */
.search-results__count{
  margin: 0 0 12px 0;
  font-size: 0.95rem;
  color: #4b5563;
}

.search-results__count strong{
  color: #111;
}

/* -------------------------
   Empty state hint banner
------------------------- */
.search-hint-banner{
  max-width: 900px;
  margin: 12px auto 0;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #f3f4f6;
  color: #374151;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  grid-column: 1 / -1;
  justify-self: center;
  box-sizing: border-box;
}

.search-hint-banner__title{
  margin: 0 0 8px 0;
  font-weight: 700;
  color: #111;
}

.search-hint-banner__text{
  margin: 0 0 8px 0;
  font-size: 0.95rem;
  color: #4b5563;
  line-height: 1.4;
}

.search-hint-banner__steps{
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.search-hint-banner__steps li{
  color: #4b5563;
}

/* -------------------------
   Payment wait banner
------------------------- */
.payment-wait-banner{
  max-width: 900px;
  margin: 0 auto 18px;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  display: flex;
  gap: 14px;
  align-items: center;
  box-sizing: border-box;
}

.payment-wait-banner[hidden]{
  display: none;
}

.payment-wait-banner__spinner{
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #d7def0;
  border-top-color: #2f55d4;
  animation: search-spin 0.9s linear infinite;
  flex: 0 0 auto;
}

@keyframes search-spin{
  to { transform: rotate(360deg); }
}

.payment-wait-banner__content{
  display: grid;
  gap: 6px;
}

.payment-wait-banner__title{
  font-weight: 700;
  color: #111;
}

.payment-wait-banner__text{
  color: #4b5563;
  font-size: 0.95rem;
  line-height: 1.4;
}

.payment-wait-banner__support{
  color: #2f55d4;
  font-weight: 600;
  text-decoration: none;
}

.payment-wait-banner__support:hover{
  text-decoration: underline;
}

/* -------------------------
   Channel card
------------------------- */
.channel-card{
  min-width: 0;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  position: relative;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.channel-card:hover{
  border-color: #d7def0;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.channel-card__overlay-link{
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
}

.channel-card__content{
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.channel-card__top{
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  align-items: start;
}

.channel-card__text{
  min-width: 0;
}

.channel-card__logo img{
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: #f3f4f6;
}

.channel-card__similarity{
  margin-top: 6px;
  padding: 3px 6px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  background: #eef2ff;
  color: #1f2a6b;
  border: 1px solid #dbe4ff;
}

.channel-card__title{
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  color: #111;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.channel-card__created{
  font-size: 0.75rem;
  color: #9ca3af;
  line-height: 1.2;
}

.channel-card__about{
  margin: 6px 0 0 0;
  color: #666;
  font-size: 0.9rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;

  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;

  min-height: calc(1.25em * 3);
}

.channel-card__tags{
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
}

.channel-tag{
  flex: 0 0 auto;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;

  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1.2;

  background: #eef2ff;
  color: #1f2a6b;
  border: 1px solid #dbe4ff;
}

.channel-tag--muted{
  background: #f3f4f6;
  color: #6b7280;
  border-color: #e5e7eb;
}

.channel-card__stats{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #eef1f4;
  margin-top: auto;
}

.stat{
  min-width: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stat-icon{
  width: 16px;
  height: 16px;
  opacity: 0.75;
}

.stat-text{
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9aa3b2;
}

.stat-value{
  display: block;
  font-weight: 800;
  font-size: 0.95rem;
  color: #111;
}

.sr-only{
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------
   Tooltips (minimal, custom)
------------------------- */
.tooltip-target{
  position: relative;
}

.tooltip-target::after{
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 6px);
  padding: 6px 10px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  max-width: 280px;
  white-space: normal;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
  z-index: 5;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

.tooltip-target::before{
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translate(-50%, 6px);
  border: 6px solid transparent;
  border-top-color: #111827;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
  z-index: 5;
}

.tooltip-target:hover::after,
.tooltip-target:focus-visible::after,
.tooltip-target:hover::before,
.tooltip-target:focus-visible::before{
  opacity: 1;
  transform: translate(-50%, 0);
}

.channel-card__cpm-label {
  margin-top: 8px;
}

.channel-card__cpm-label .cpm-label {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* Actions: left icons + right details */
.channel-card__actions{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  pointer-events: auto;
}

.channel-card__actions-left{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

/* Telegram icon button */
.tg-icon-btn{
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 10px;
  text-decoration: none;
  pointer-events: auto;
}

.tg-icon-btn__icon{
  width: 24px;
  height: 24px;
  display: block;
  transition: transform .12s ease, opacity .15s ease;
}

.tg-icon-btn:hover .tg-icon-btn__icon{
  transform: scale(1.06);
  opacity: 0.95;
}

.tg-icon-btn:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 85, 212, 0.2);
}

.tg-icon-btn--disabled{
  opacity: .55;
  cursor: not-allowed;
}

/* Heart like button (PNG) */
.fav-like-btn{
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 10px;
  pointer-events: auto;
}

.fav-like-img{
  width: 22px;
  height: 22px;
  display: block;
  transition: transform .12s ease, opacity .15s ease;
}

.fav-like-btn:hover .fav-like-img{
  transform: scale(1.06);
  opacity: 0.95;
}

.fav-like-btn:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 85, 212, 0.2);
}

/* Details link */
.details-link{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 14px 0 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;

  background: #fff;
  color: #2f55d4;
  border: 1px solid #d7def0;
  pointer-events: auto;
  transition: background .15s ease, box-shadow .15s ease, transform .15s ease, color .15s ease, border-color .15s ease;
  gap: 6px;
}

.details-link:hover{
  background: #2f55d4;
  color: #fff;
  border-color: #2f55d4;
  box-shadow: 0 8px 16px rgba(47, 85, 212, 0.2);
  transform: translateY(-1px);
}

.details-link:active{
  transform: translateY(0);
}

.channel-card__actions-center{
  display: flex;
  align-items: center;
  pointer-events: auto;
}

.channel-card__actions-center .cpm-label{
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* -------------------------
   Load more + auth banner
------------------------- */
.load-more-container{
  text-align: center;
  margin-top: 20px;
}

.load-more-btn{
  padding: 12px 24px;
  background: #2f55d4;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s ease;
}

.load-more-btn:hover{
  background: #2542b0;
}

.load-more-btn:disabled,
.load-more-btn.btn-loading{
  background: #ccc;
  cursor: not-allowed;
}

.bottom-auth-banner{
  text-align: center;
  padding: 28px 20px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  margin-top: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.bottom-auth-banner h3{
  margin: 0 0 10px 0;
}

.bottom-auth-banner p{
  margin: 0 0 20px 0;
  color: #666;
}

.bottom-auth-btn{
  display: inline-block;
  padding: 12px 24px;
  background: #2f55d4;
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  font-weight: 700;
}

.bottom-auth-btn:hover{
  background: #2542b0;
}

/* -------------------------
   Similar section headings (detail page uses search.css too)
------------------------- */
.similar-channels{
  margin-top: 24px;
}

.similar-channels h3{
  margin: 0 0 12px 0;
  font-size: 1.25rem;
  color: #111;
}

/* -------------------------
   Responsive
------------------------- */
@media (max-width: 1100px){
  .channels-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Раньше переключаем advanced-grid в 1 колонку (важно для мобильных) */
@media (max-width: 900px){
  .advanced-fields,
  .advanced-fields--numbers{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px){
  .channels-grid{
    grid-template-columns: 1fr;
  }

  .search-controls-row{
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .search-control-block{
    width: 100%;
    justify-content: space-between;
  }

  .sort-control{
    justify-content: space-between;
  }

  .search-reset--inline{
    width: 100%;
  }

  /* на очень узких экранах разрешаем перенос текста кнопок */
  .filters-toggle,
  .filters-reset--inline{
    white-space: normal;
  }

  .only-favs-text{
    white-space: normal;
  }
}

/* Мелкие экраны: строка поиска в столбик */
@media (max-width: 520px){
  .search-input-wrap{
    flex-direction: column;
    align-items: stretch;
  }

  .search-submit{
    width: 100%;
  }

  .search-submit-row{
    justify-content: stretch;
  }
}

/* Paywall / limit exceeded block should span full grid width */
.channels-grid > .limit-exceeded,
.channels-grid > .subscription-plans,
.channels-grid > .paywall,
.channels-grid > .quota-exceeded,
.channels-grid > .limit-banner {
  grid-column: 1 / -1;
}
/* Paywall spans across the whole results grid */
.channels-grid > .limit-exceeded{
  grid-column: 1 / -1;
  width: 100%;
}

/* Чтобы выглядел как широкий центрированный блок */
.limit-exceeded{
  max-width: 860px;      /* как search-bar */
  margin: 10px auto 0;
}

/* Paywall banner on search page */
.paywall-banner{
  max-width: 860px;
  margin: 0 auto 18px;
}

.paywall-banner[hidden]{
  display: none;
}