/* ============================================================
   WatchLane — browse.css
   Style untuk halaman browse.html dan search.html
   Import: tokens.css wajib dimuat sebelum file ini
   ============================================================ */

/* ── PAGE HEADER ──────────────────────────────────────────── */
.page-header {
  padding: calc(var(--nav-h) + 32px) 40px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 12px;
  font-family: 'Space Grotesk', sans-serif;
}

.page-breadcrumb a {
  color: var(--text-2);
  transition: color 0.2s;
}

.page-breadcrumb a:hover {
  color: var(--red);
}

.page-breadcrumb span {
  color: var(--text-3);
}

.page-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-2);
}

/* ── BROWSE LAYOUT ────────────────────────────────────────── */
.browse-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 32px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 40px 64px;
  align-items: start;
}

/* ── FILTER SIDEBAR ───────────────────────────────────────── */
.filter-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 16px);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  max-height: calc(100vh - var(--nav-h) - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) transparent;
}

.filter-sidebar::-webkit-scrollbar {
  width: 4px;
}

.filter-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 2px;
}

.filter-section {
  margin-bottom: 24px;
}

.filter-section:last-of-type {
  margin-bottom: 0;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-3);
  font-family: 'Space Grotesk', sans-serif;
  margin-bottom: 10px;
  display: block;
}

/* Genre Checkboxes */
.filter-genre-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) transparent;
}

.filter-genre-list::-webkit-scrollbar {
  width: 3px;
}

.filter-genre-list::-webkit-scrollbar-thumb {
  background: var(--border-hi);
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-2);
  transition: color 0.15s;
  user-select: none;
}

.filter-check:hover {
  color: var(--text-1);
}

.filter-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-hi);
  border-radius: 4px;
  background: var(--surface-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.filter-check input[type="checkbox"]:checked {
  background: var(--red);
  border-color: var(--red);
}

.filter-check input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: white;
  font-weight: 700;
}

.filter-check input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-hi);
  border-radius: 50%;
  background: var(--surface-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s;
  position: relative;
}

.filter-check input[type="radio"]:checked {
  border-color: var(--red);
}

.filter-check input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
}

/* Select Dropdowns */
.filter-select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23A0A3B1' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  transition: border-color 0.2s;
}

.filter-select:focus {
  outline: none;
  border-color: var(--red-border);
}

.filter-select option {
  background: var(--surface-2);
  color: var(--text-1);
}

/* Rating Slider */
.filter-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-slider {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.filter-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  cursor: pointer;
  box-shadow: var(--red-shadow);
  transition: transform 0.15s;
}

.filter-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.filter-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  cursor: pointer;
  border: none;
  box-shadow: var(--red-shadow);
}

.filter-slider-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  font-family: 'Space Grotesk', sans-serif;
  min-width: 28px;
  text-align: right;
}

/* Filter Actions */
.filter-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.btn-apply-filter {
  width: 100%;
  padding: 10px;
  background: var(--red);
  color: white;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, transform 0.15s;
  font-family: 'Inter', sans-serif;
}

.btn-apply-filter:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-apply-filter:active {
  transform: translateY(0);
}

.btn-reset-filter {
  width: 100%;
  padding: 9px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  font-family: 'Inter', sans-serif;
}

.btn-reset-filter:hover {
  border-color: var(--border-hi);
  color: var(--text-1);
}

/* Active Filters Chips */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--red-dim);
  border: 1px solid var(--red-border);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 12px;
  color: var(--text-1);
  font-family: 'Space Grotesk', sans-serif;
}

.filter-chip__remove {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  background: none;
  border: none;
  color: inherit;
}

.filter-chip__remove:hover {
  opacity: 1;
}

/* ── BROWSE MAIN CONTENT ──────────────────────────────────── */
.browse-main {
  min-height: 60vh;
}

/* Toolbar: count + sort */
.browse-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.browse-count {
  font-size: 14px;
  color: var(--text-2);
}

.browse-count strong {
  color: var(--text-1);
}

.browse-sort {
  display: flex;
  align-items: center;
  gap: 10px;
}

.browse-sort label {
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
}

.browse-sort .filter-select {
  width: auto;
  min-width: 160px;
}

/* Browse Grid */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

.browse-grid .card-poster {
  width: 100%;
}

.browse-grid .card-poster__img-wrap {
  width: 100%;
  padding-bottom: 150%;
  height: 0;
  position: relative;
}

.browse-grid .card-poster__img-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Skeleton grid */
.browse-grid-skeleton {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.browse-skeleton-card {
  aspect-ratio: 2/3;
  border-radius: var(--r-md);
  background: var(--surface-2);
  animation: shimmer 1.8s infinite linear;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
}

/* Infinite Scroll Sentinel */
.scroll-sentinel {
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
}

.scroll-sentinel .spinner {
  display: none;
}

.scroll-sentinel.loading .spinner {
  display: block;
}

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.empty-state__icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-state__title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state__text {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 24px;
  max-width: 360px;
}

.empty-state__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── WATCHLIST / HISTORY SPECIAL VIEW ─────────────────────── */
.special-view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.special-view-icon {
  font-size: 32px;
}

.special-view-header h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 28px;
  font-weight: 700;
}

.special-view-header p {
  font-size: 13px;
  color: var(--text-2);
}

.clear-history-btn {
  margin-left: auto;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.clear-history-btn:hover {
  border-color: var(--red-border);
  color: var(--red);
}

/* ── SEARCH PAGE ──────────────────────────────────────────── */
.search-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 40px 64px;
}

.search-header {
  padding-top: calc(var(--nav-h) + 32px);
  margin-bottom: 28px;
}

.search-query-label {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.search-query-text {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 700;
}

.search-query-text em {
  font-style: normal;
  color: var(--red);
}

.search-count {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 6px;
  font-family: 'Space Grotesk', sans-serif;
}

/* Type Filter Pills */
.search-type-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.type-pill {
  padding: 7px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}

.type-pill:hover {
  border-color: var(--border-hi);
  color: var(--text-1);
}

.type-pill.active {
  background: var(--red);
  border-color: var(--red);
  color: white;
  box-shadow: var(--red-shadow);
}

/* Search Sort Bar */
.search-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 20px;
  gap: 10px;
}

.search-toolbar label {
  font-size: 13px;
  color: var(--text-3);
}

/* Search Results Grid */
.search-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

.search-grid .card-poster {
  width: 100%;
}

.search-grid .card-poster__img-wrap {
  width: 100%;
  padding-bottom: 150%;
  height: 0;
  position: relative;
}

.search-grid .card-poster__img-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Highlight matching text */
.hl {
  font-weight: 700;
  color: var(--red);
}

/* ── MOBILE FILTER BUTTON (fixed) ─────────────────────────── */
.filter-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  padding: 12px 20px;
  background: var(--red);
  color: white;
  border-radius: 32px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  box-shadow: var(--red-shadow-lg);
  align-items: center;
  gap: 8px;
  animation: slideUp 0.3s ease;
  transition: opacity 0.2s, transform 0.15s;
}

.filter-fab:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.filter-fab:active {
  transform: translateY(0);
}

.filter-fab .filter-fab__count {
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 12px;
}

/* ── FILTER MODAL (mobile) ────────────────────────────────── */
.filter-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 900;
  animation: fadeIn 0.2s ease;
}

.filter-modal-overlay.open {
  display: block;
}

.filter-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-1);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 20px 20px 32px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 901;
  animation: slideUp 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.filter-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.filter-modal-header h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.filter-modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-2);
  transition: color 0.2s;
}

.filter-modal-close:hover {
  color: var(--text-1);
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1200px) {
  .browse-grid,
  .browse-grid-skeleton,
  .search-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 1024px) {
  .browse-layout {
    grid-template-columns: 200px 1fr;
    gap: 20px;
    padding: 0 24px 48px;
  }

  .browse-grid,
  .browse-grid-skeleton,
  .search-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .page-header {
    padding: calc(var(--nav-h) + 24px) 24px 20px;
  }

  .search-layout {
    padding: 0 24px 48px;
  }
}

@media (max-width: 768px) {
  /* Sidebar tersembunyi di mobile */
  .filter-sidebar {
    display: none;
  }

  .browse-layout {
    grid-template-columns: 1fr;
    padding: 0 16px 80px;
  }

  .page-header {
    padding: calc(var(--nav-h) + 16px) 16px 16px;
  }

  .browse-grid,
  .browse-grid-skeleton,
  .search-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .browse-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .browse-sort {
    width: 100%;
  }

  .browse-sort .filter-select {
    flex: 1;
    min-width: 0;
  }

  /* Show FAB */
  .filter-fab {
    display: flex;
  }

  .search-layout {
    padding: 0 16px 80px;
  }

  .search-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .search-type-filter {
    gap: 6px;
  }

  .type-pill {
    padding: 6px 14px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .browse-grid,
  .browse-grid-skeleton,
  .search-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}
