/* TOPBAR (NAV + SEARCH) */
.header{padding:0;display:flex;align-items:center}
.header .container{height:100%;display:flex;align-items:center;gap:16px;padding:0}
.header-left{display:flex;align-items:center;gap:16px;min-width:0}
.header-nav{display:flex;align-items:center;gap:8px;min-width:0}
.header-search{margin-left:auto;display:flex;align-items:center;min-width:280px;max-width:460px;flex:1 1 360px}
.header-right{display:flex;align-items:center;gap:10px;flex:0 0 auto}

.search-shell{
  position:relative;
  display:flex;
  align-items:center;
  width:100%;
  height:46px;
  padding:0 12px 0 14px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.08);
  background:linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.03));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.02);
  transition:border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.search-shell:focus-within{
  border-color:rgba(255,77,90,.32);
  box-shadow:0 0 0 4px rgba(255,77,90,.10);
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.04));
}

.search-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  color:var(--muted);
  flex:0 0 auto;
}

.search-icon svg{
  width:18px;
  height:18px;
  stroke:currentColor;
  fill:none;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.search{
  flex:1;
  min-width:0;
  height:100%;
  padding:0 10px;
  border:none;
  background:transparent;
  color:var(--text);
  outline:none;
  font-size:14px;
  appearance:none;
  -webkit-appearance:none;
}

.search::placeholder{color:var(--muted)}

.search-clear{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:32px;
  height:32px;
  padding:0;
  border:none;
  border-radius:10px;
  background:transparent;
  color:var(--muted);
  cursor:pointer;
  opacity:0;
  pointer-events:none;
  transform:scale(.96);
  transition:opacity .16s ease, transform .16s ease, background .16s ease, color .16s ease;
}

.search-clear.is-active{
  opacity:1;
  pointer-events:auto;
  transform:scale(1);
}

.search-clear:hover,
.search-clear:focus-visible{
  background:rgba(255,255,255,.08);
  color:var(--text);
}

.search-clear svg{
  width:16px;
  height:16px;
  stroke:currentColor;
  fill:none;
  stroke-width:2;
  stroke-linecap:round;
}

.filters-inline,
.popular-block{
  width:100%;
  border:1px solid var(--border);
  background:linear-gradient(180deg, rgba(14,20,36,.88), rgba(8,12,22,.95));
  box-shadow:var(--shadow-md);
}

.filters-inline{
  display:block;
  margin-top:18px;
  padding:16px;
  border-radius:28px;
  overflow:hidden;
}

.filters-row{
  display:flex;
  align-items:flex-end;
  gap:10px;
  flex-wrap:nowrap;
  width:100%;
  overflow-x:auto;
  padding-bottom:2px;
  scrollbar-width:none;
}

.filters-row::-webkit-scrollbar{display:none}
.filters-row-catalog{min-width:max-content}

.fi{
  display:flex;
  flex-direction:column;
  gap:7px;
  min-width:0;
  flex:0 0 auto;
}

.fi-label{
  padding-left:2px;
  font-size:10px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.14em;
}

.fi-searchable{width:158px}
.fi-country{width:150px}
.fi-status{width:148px}
.fi-tags{width:152px}
.fi-years-wrap{width:148px}
.fi-rating{width:88px}
.fi-scope{width:198px}

.filters-inline .input-sm,
.filters-inline .select-sm,
.filters-inline .btn-sm,
.fi-btn{
  height:36px;
  border-radius:12px;
  font-size:13px;
}

.filters-inline .input-sm,
.filters-inline .select-sm,
.fi-btn,
.seg{
  border:1px solid rgba(255,255,255,.08);
  background:linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.025));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.02);
}

.filters-inline .input-sm,
.filters-inline .select-sm{
  padding:0 12px;
}

.filters-inline .input-sm:focus,
.filters-inline .select-sm:focus,
.fi-btn:focus-visible{
  border-color:rgba(255,77,90,.34);
  box-shadow:0 0 0 4px rgba(255,77,90,.10);
}

.fi-btn{
  color:var(--text);
  cursor:pointer;
  padding:0 12px;
  text-align:left;
  transition:border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.fi-btn:hover{
  border-color:rgba(255,255,255,.14);
  background:linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
}

.fi-btn.is-selected{
  border-color:rgba(255,77,90,.28);
  background:linear-gradient(180deg, rgba(255,77,90,.14), rgba(255,77,90,.08));
}

.fi-btn-search,
.fi-btn-choice{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.fi-btn-search::after,
.fi-btn-choice::after{
  flex:0 0 auto;
  color:var(--muted);
  font-size:12px;
}

.fi-btn-search::after{content:'⌕'}
.fi-btn-choice::after{content:'▾'}

.fi-years{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:6px;
}

.fi-actions{
  display:flex;
  gap:8px;
  align-items:flex-end;
  flex:0 0 auto;
  margin-left:auto;
  padding-left:0;
}

.fi-actions .btn-sm{
  width:104px;
  min-width:104px;
  justify-content:center;
  padding:0 16px;
}

.popular-block{
  margin-top:18px;
  padding:18px;
  gap:12px;
  border-radius:30px;
}

.popular-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px}
.popular-title{font-weight:900;font-size:18px;letter-spacing:-.02em}
.popular-row{display:flex;gap:16px;overflow:auto;scroll-behavior:smooth;padding:0 0 6px;scrollbar-width:none;scroll-snap-type:x mandatory}
.popular-row::-webkit-scrollbar{display:none}
.popular-strip{position:relative}
.popular-arrow{
  position:absolute;top:50%;transform:translateY(-50%);width:42px;height:42px;border:none;border-radius:0;
  background:transparent;color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;z-index:3;
  font-size:54px;line-height:1;text-shadow:0 4px 16px rgba(0,0,0,.42);padding:0;opacity:.92
}
.popular-arrow:hover{opacity:1;transform:translateY(-50%) scale(1.04)}
.popular-arrow-prev{left:18px}.popular-arrow-next{right:18px}
.popular-row .movie-card{flex:0 0 var(--movie-rail-card-w);width:var(--movie-rail-card-w);scroll-snap-align:start}

.section-head{display:flex;align-items:flex-end;justify-content:space-between;gap:18px;margin:14px 0 16px}
.section-head h2{margin:0;font-size:28px;letter-spacing:-.03em}
.chips{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end}
.chip{
  display:inline-flex;align-items:center;gap:8px;padding:8px 12px;border-radius:999px;
  background:rgba(255,255,255,.04);border:1px solid var(--border);color:var(--muted);font-size:12px
}
.chip strong{color:var(--text)}
.chip button{border:none;background:transparent;color:var(--muted);cursor:pointer;font-size:14px;line-height:1}

.popover{
  --popover-width:332px;
  --popover-max-height:392px;
  position:fixed;
  top:calc(var(--topbar-h) + 24px);
  left:12px;
  width:min(var(--popover-width), calc(100vw - 24px));
  max-width:calc(100vw - 24px);
  max-height:min(var(--popover-max-height), calc(100vh - 96px));
  background:linear-gradient(180deg, rgba(18,26,46,.98), rgba(8,12,22,.98));
  border:1px solid rgba(255,255,255,.08);
  border-radius:20px;
  box-shadow:var(--shadow-lg);
  backdrop-filter:blur(16px);
  display:none;
  flex-direction:column;
  z-index:4000;
  overflow:hidden;
}

.popover.open{display:flex}
.popover-status{
  --popover-width:286px;
  --popover-max-height:300px;
}
#genrePopover,
#countryPopover{
  --popover-width:340px;
  --popover-max-height:368px;
}
#tagsPopover{
  --popover-width:332px;
  --popover-max-height:380px;
}

.popover-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  border-bottom:1px solid rgba(255,255,255,.06);
}

.popover-title{font-weight:800}

.popover-body{
  padding:12px 14px 14px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height:0;
}

#genrePopover .popover-head,
#countryPopover .popover-head{
  padding:12px 14px;
}

#genrePopover .popover-body,
#countryPopover .popover-body{
  padding:12px 14px 14px;
  gap:10px;
  overflow:hidden;
}

#genreSearch,
#countrySearch{
  width:100%;
  height:42px;
  min-height:42px;
  padding:0 14px;
  border-radius:14px;
  font-size:14px;
  flex:0 0 auto;
}

.popover-body::-webkit-scrollbar{width:8px}
.popover-body::-webkit-scrollbar-thumb{background:rgba(255,255,255,.10);border-radius:999px}

.gline{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  min-height:42px;
  border-radius:14px;
  border:1px solid transparent;
  background:rgba(255,255,255,.02);
  cursor:pointer;
  transition:background .16s ease, border-color .16s ease, transform .16s ease;
}

#genreList,
#countryList,
#statusList,
#tagsList{
  display:flex;
  flex-direction:column;
  gap:6px;
}

#genreList,
#countryList{
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  padding-right:4px;
  margin-right:-4px;
  scrollbar-width:thin;
}

#genreList::-webkit-scrollbar,
#countryList::-webkit-scrollbar{width:8px}
#genreList::-webkit-scrollbar-thumb,
#countryList::-webkit-scrollbar-thumb{background:rgba(255,255,255,.10);border-radius:999px}

#genrePopover .gline,
#countryPopover .gline{
  min-height:38px;
  padding:8px 10px;
  border-radius:12px;
}

.gline:hover{
  background:rgba(255,255,255,.05);
  border-color:rgba(255,255,255,.08);
  transform:translateY(-1px);
}

.gline input{accent-color:var(--accent);flex:0 0 auto;margin:0}
.gline span{font-size:13px;line-height:1.35}
.gline.is-empty{opacity:.76;cursor:default}
.gline.is-empty:hover{border-color:transparent;background:rgba(255,255,255,.02);transform:none}

.popover-group{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.popover-group-title{
  padding:4px 2px 0;
  color:var(--muted);
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.12em;
}

.seg{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  align-items:center;
  width:100%;
  border-radius:12px;
  padding:3px;
  gap:3px;
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
}

.seg-btn{
  height:30px;
  padding:0 10px;
  border-radius:9px;
  border:none;
  background:transparent;
  color:var(--muted);
  cursor:pointer;
  font-size:12px;
  font-weight:600;
  white-space:nowrap;
  transition:background .16s ease, color .16s ease, box-shadow .16s ease;
}

.seg-btn.active{
  background:linear-gradient(135deg, rgba(255,77,90,.30), rgba(225,29,72,.22));
  color:var(--text);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.08), 0 8px 18px rgba(225,29,72,.18);
}
.seg-btn:hover{color:var(--text);background:rgba(255,255,255,.05)}
.seg-btn.active:hover{background:linear-gradient(135deg, rgba(255,77,90,.34), rgba(225,29,72,.24))}

@media(max-width:1100px){
  .filters-inline,
  .popular-block{padding:14px;border-radius:24px}
  .fi-searchable{width:152px}
  .fi-country{width:146px}
  .fi-status{width:142px}
  .fi-tags{width:146px}
  .fi-scope{width:188px}
  .fi-actions .btn-sm{width:96px;min-width:96px}
}

@media(max-width:900px){
  .header .container{padding:0}
  .header-nav{overflow:auto;scrollbar-width:none}
  .header-nav::-webkit-scrollbar{display:none}
  .header-search{min-width:180px;max-width:none}
  .popover{max-width:calc(100vw - 20px)}
  #genrePopover,
  #countryPopover,
  #tagsPopover,
  .popover-status{width:min(var(--popover-width), calc(100vw - 20px))}
}


@media (min-width:1280px){
  .popular-row .movie-card{
    width:calc((100% - 80px) / 6);
    flex:0 0 calc((100% - 80px) / 6);
  }
}

@media(max-width:900px){
  .popular-arrow{font-size:44px;width:36px;height:36px}
}

@media(max-width:560px){
  .popular-arrow{font-size:34px;width:28px;height:28px}
  .popular-arrow-prev{left:8px}
  .popular-arrow-next{right:8px}
}

@media (min-width:1200px){
  .popular-row .movie-card{
    width:calc((100% - 80px) / 6);
    min-width:calc((100% - 80px) / 6);
    flex:0 0 calc((100% - 80px) / 6);
  }
}
