/* Gallery Filter Integration for Netflix-Style Gallery */
:root {
  --filter-bg: rgba(0, 0, 0, 0.3);
  --filter-btn-bg: rgba(255, 255, 255, 0.15);
  --filter-btn-color: #ffffff;
  --filter-btn-active-bg: var(--primary-color);
  --filter-btn-active-color: #ffffff;
  --filter-btn-hover-bg: rgba(255, 255, 255, 0.25);
  --search-bg: rgba(255, 255, 255, 0.15);
  --search-text: #ffffff;
  --search-placeholder: rgba(255, 255, 255, 0.7);
  --search-button-bg: var(--primary-color);
}

/* Filter Header Strip - Spans full width outside grid */
.gallery-filter-header {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 998; /* Below navbar (1000) but above content */
  position: relative;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  grid-column: 1 / -1;
  margin-left: -4%;
  margin-right: -4%;
  margin-top: -30px;
}

/* Fixed state when scrolling - for cloned header */
#cloned-filter-header.fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 998;
  background: rgba(0, 0, 0, 0.6);
  will-change: opacity, transform;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Hidden state for cloned header */
#cloned-filter-header.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

/* Visible state for cloned header */
#cloned-filter-header.fixed:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Disable original header when cloned is active */
.gallery-filter-header.original-inactive {
  pointer-events: none;
  user-select: none;
}

/* Placeholder to prevent content jump */
.filter-header-placeholder {
  display: none;
  width: 100%;
}

.filter-header-placeholder.active {
  display: block;
}

/* Filter Container */
.gallery-filter-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4%;
  margin-bottom: 0;
  background-color: transparent;
  border-radius: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Filter Title */
.filter-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-color);
  margin-right: 15px;
  white-space: nowrap;
}

/* Filter Navigation */
.filter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 5px 0;
}

.filter-btn {
  background-color: var(--filter-btn-bg);
  color: var(--filter-btn-color);
  border: none;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn:hover {
  background-color: var(--filter-btn-hover-bg);
  transform: translateY(-2px);
}

.filter-btn.active {
  background-color: var(--filter-btn-active-bg);
  color: var(--filter-btn-active-color);
}

/* Search Container */
.search-container {
  display: flex;
  flex-direction: column;
  position: relative;
  margin: 5px 0;
  min-width: 200px;
  max-width: 300px;
  flex-grow: 1;
}

#gallery-search {
  width: 100%;
  padding: 8px 40px 8px 15px;
  border: none;
  border-radius: 30px;
  background-color: var(--search-bg);
  color: var(--search-text);
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.3s ease;
}

#gallery-search::placeholder {
  color: var(--search-placeholder);
}

#gallery-search:focus {
  background-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 2px var(--primary-color);
}

#search-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background-color: transparent;
  border: none;
  color: var(--text-color);
  font-size: 0.9rem;
  padding: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#search-btn:hover {
  color: var(--primary-color);
}

/* Gallery cards when filtered - with smooth animations */
.content-card {
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.3s ease, transform 0.3s ease;
  will-change: opacity, transform;
}

.content-card.hidden {
  display: none;
}

/* Stagger animation for cards appearing */
.content-card:not(.hidden):nth-child(1) {
  animation: fadeInScale 0.4s ease 0.05s both;
}
.content-card:not(.hidden):nth-child(2) {
  animation: fadeInScale 0.4s ease 0.1s both;
}
.content-card:not(.hidden):nth-child(3) {
  animation: fadeInScale 0.4s ease 0.15s both;
}
.content-card:not(.hidden):nth-child(4) {
  animation: fadeInScale 0.4s ease 0.2s both;
}
.content-card:not(.hidden):nth-child(5) {
  animation: fadeInScale 0.4s ease 0.25s both;
}
.content-card:not(.hidden):nth-child(6) {
  animation: fadeInScale 0.4s ease 0.3s both;
}
.content-card:not(.hidden):nth-child(7) {
  animation: fadeInScale 0.4s ease 0.35s both;
}
.content-card:not(.hidden):nth-child(8) {
  animation: fadeInScale 0.4s ease 0.4s both;
}
.content-card:not(.hidden):nth-child(9) {
  animation: fadeInScale 0.4s ease 0.45s both;
}
.content-card:not(.hidden):nth-child(10) {
  animation: fadeInScale 0.4s ease 0.5s both;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Content rows smooth transitions */
.content-row {
  transition: opacity 0.3s ease, max-height 0.4s ease;
  overflow: hidden;
}

.content-row.hidden {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding: 0;
}

/* Highlight animation for filtered content */
@keyframes highlightCard {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 140, 255, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(0, 140, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 140, 255, 0);
  }
}

.content-card.highlight {
  animation: highlightCard 1.5s ease;
}

/* Results Message */
.filter-results {
  text-align: center;
  padding: 20px 0;
  color: var(--text-color);
  font-size: 1.2rem;
  width: 100%;
  display: none;
}

.filter-results.active {
  display: block;
}

.filter-results.no-results {
  font-style: italic;
  opacity: 0.8;
}

/* Content row display states */
.content-row.hidden {
  display: none;
}

.content-row.empty .row-container:after {
  content: "No items match your current filter criteria in this category.";
  display: block;
  width: 100%;
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
}

/* Hide row headers when "All Content" filter is active */
.netflix-gallery.show-all-content .content-row .row-header {
  display: none !important;
}

/* All Content unified layout for mobile */
@media (max-width: 768px) {
  .netflix-gallery.show-all-content .content-row {
    display: none;
  }

  .netflix-gallery.show-all-content .unified-mobile-row {
    display: block;
  }
}

/* Unified mobile row container */
.unified-mobile-row {
  display: none;
  padding: 20px 0;
  position: relative;
}

.unified-mobile-row .row-header {
  display: none;
}

.unified-mobile-row .row-container {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 15px;
  padding: 0 4%;
}

.unified-mobile-row .row-container::-webkit-scrollbar {
  display: none;
}

.unified-mobile-row .content-card {
  flex: 0 0 280px;
  scroll-snap-align: start;
}

/* Responsive adjustments */
@media (max-width: 992px) {
  .gallery-filter-container {
    flex-direction: column;
    align-items: center;
    padding: 10px 4%;
  }

  .filter-nav {
    margin: 8px 0;
    width: 100%;
    justify-content: center;
  }

  .search-container {
    margin: 8px 0;
    max-width: 100%;
    width: 100%;
  }
}

@media (max-width: 768px) {
  /* Adjust sticky position for smaller navbar on mobile */
  .gallery-filter-header {
    top: 70px; /* Smaller navbar on mobile */
    margin-left: 0;
    margin-right: 0;
    margin-top: 0;
  }

  .gallery-filter-container {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 4%;
    margin-top: 0;
    position: relative;
    z-index: 10;
    align-items: center;
    justify-content: center;
  }

  .filter-title {
    display: none;
  }

  .filter-nav {
    gap: 8px;
    margin: 8px 0;
  }

  .filter-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
    min-height: 44px;
  }

  #gallery-search {
    font-size: 0.85rem;
    padding: 10px 40px 10px 15px;
    min-height: 44px;
  }

  #search-btn {
    font-size: 1rem;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 576px) {
  .gallery-filter-container {
    padding: 8px 2%;
  }

  .filter-nav {
    gap: 6px;
    flex-wrap: wrap;
  }

  .filter-btn {
    padding: 7px 12px;
    font-size: 0.8rem;
    min-height: 44px;
  }

  .filter-title {
    font-size: 0.85rem;
    margin-bottom: 6px;
  }

  #gallery-search {
    font-size: 0.8rem;
    padding: 9px 38px 9px 12px;
    min-height: 44px;
  }

  #search-btn {
    font-size: 0.9rem;
    padding: 6px;
    min-width: 44px;
    min-height: 44px;
  }

  .search-indicator {
    margin: 12px 2% 20px 2%;
    padding: 10px 12px;
  }

  .search-indicator-text {
    font-size: 0.85rem;
  }

  .clear-search-btn {
    padding: 7px 13px;
    font-size: 0.85rem;
    min-height: 44px;
  }
}

/* Very small screens - adjust sticky position further */
@media (max-width: 480px) {
  .gallery-filter-header {
    top: 60px; /* Even smaller navbar on very small screens */
  }
}

/* Search-specific styles */
.search-dimmed {
  opacity: 0.3;
  filter: grayscale(50%);
  transition: all 0.3s ease;
}

.search-dimmed:hover {
  opacity: 0.6;
}

.search-empty-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-style: italic;
  opacity: 0.7;
}

.search-empty-message p {
  margin: 0;
  font-size: 1rem;
}

.search-indicator {
  background-color: rgba(0, 140, 255, 0.1);
  border: 1px solid rgba(0, 140, 255, 0.3);
  border-radius: 8px;
  padding: 15px 20px;
  margin: 20px 4% 30px 4%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.search-indicator-content {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

.search-indicator-text {
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 500;
}

.clear-search-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.clear-search-btn:hover {
  background-color: rgba(0, 140, 255, 0.8);
  transform: translateY(-1px);
}

.highlight-text {
  background-color: rgba(255, 255, 0, 0.3);
  color: #fff;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 3px;
}

/* Reset button styling */
.reset-search {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.reset-search:hover {
  background-color: rgba(0, 140, 255, 0.8);
}

@media (max-width: 768px) {
  .search-indicator {
    margin: 15px 2% 20px 2%;
    padding: 12px 15px;
  }

  .search-indicator-content {
    flex-direction: column;
    gap: 10px;
  }

  .search-indicator-text {
    font-size: 0.9rem;
    text-align: center;
  }
}

/* Tag Dropdown System Styles */
.search-input-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.tag-dropdown-container {
  position: relative;
  width: 100%;
  margin-top: 10px;
}

.tag-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background-color: rgba(20, 20, 20, 0.98);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

.tag-dropdown-panel.active {
  max-height: 600px;
  opacity: 1;
  transform: translateY(0);
  overflow-y: auto;
}

.tag-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 0 0 15px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  background-color: rgba(20, 20, 20, 0.98);
  z-index: 10;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.tag-dropdown-close {
  display: none;
  background: none;
  border: none;
  color: #008cff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  margin-right: 10px;
  transition: all 0.3s ease;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.tag-dropdown-close:hover {
  color: #fff;
  transform: translateX(-2px);
}

.tag-dropdown-title {
  font-size: 1rem;
  font-weight: 600;
  color: #008cff;
  flex: 1;
}

#tag-logic-toggle {
  padding: 6px 12px;
  background-color: rgba(0, 140, 255, 0.2);
  border: 1px solid rgba(0, 140, 255, 0.4);
  border-radius: 20px;
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

#tag-logic-toggle:hover {
  background-color: rgba(0, 140, 255, 0.3);
  border-color: #008cff;
  transform: translateY(-1px);
}

#tag-logic-toggle[data-logic="OR"] {
  background-color: rgba(0, 140, 255, 0.2);
  border-color: rgba(0, 140, 255, 0.4);
}

#tag-logic-toggle[data-logic="OR"]:hover {
  background-color: rgba(0, 140, 255, 0.3);
  border-color: #008cff;
}

.selected-tags-display {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0;
  min-height: 0;
  transition: all 0.3s ease;
}

.selected-tags-display:not(:empty) {
  display: flex;
  min-height: 40px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.selected-tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: rgba(0, 140, 255, 0.3);
  border: 1px solid rgba(0, 140, 255, 0.5);
  border-radius: 16px;
  color: #008cff;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.selected-tag-badge:hover {
  background-color: rgba(0, 140, 255, 0.4);
  border-color: #008cff;
}

.selected-tag-badge .remove-tag {
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.selected-tag-badge .remove-tag:hover {
  opacity: 1;
}

.tag-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.tag-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tag-group-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #008cff;
  margin-bottom: 5px;
}

.tag-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  width: auto;
  max-width: 100%;
}

.tag-option:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.tag-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #008cff;
}

.tag-option input[type="checkbox"]:checked + span {
  color: #008cff;
  font-weight: 500;
}

.tag-dropdown-footer {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: flex-end;
}

.clear-tags-btn {
  padding: 8px 16px;
  background-color: rgba(255, 59, 48, 0.2);
  border: 1px solid rgba(255, 59, 48, 0.4);
  border-radius: 20px;
  color: #ff3b30;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-tags-btn:hover {
  background-color: rgba(255, 59, 48, 0.3);
  border-color: #ff3b30;
  transform: translateY(-1px);
}

/* Tag badges in modals */
.modal-video-categories,
.modal-image-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 15px;
}

.tag-badge {
  display: inline-block;
  padding: 6px 12px;
  background-color: rgba(0, 140, 255, 0.15);
  border: 1px solid rgba(0, 140, 255, 0.3);
  border-radius: 16px;
  color: #008cff;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.tag-badge:hover {
  background-color: rgba(0, 140, 255, 0.25);
  border-color: #008cff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 140, 255, 0.3);
}

/* Responsive tag system */
@media (max-width: 768px) {
  .tag-filter-container {
    flex-direction: column;
    gap: 8px;
  }

  #tag-select {
    min-height: 100px;
    font-size: 13px;
  }

  #tag-logic-toggle {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    min-height: 44px;
  }

  .tag-badge {
    font-size: 0.8rem;
    padding: 5px 10px;
  }

  /* Mobile-specific tag dropdown styles */
  .tag-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    bottom: auto;
    left: 0;
    right: 0;
    border-radius: 20px;
    max-height: 0;
    padding: 15px;
    z-index: 1001;
    transform: translateY(-10px);
  }

  .tag-dropdown-panel.active {
    max-height: 70vh;
    transform: translateY(0);
  }

  .tag-dropdown-header {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 15px 15px 15px 5px;
  }

  .tag-dropdown-close {
    display: flex;
  }

  .tag-dropdown-title {
    font-size: 1.1rem;
    text-align: left;
  }

  .tag-groups {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .tag-options {
    align-items: flex-start;
  }

  .tag-option {
    padding: 10px 12px;
    min-height: 44px;
  }

  .tag-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
  }

  .clear-tags-btn {
    width: 100%;
    padding: 12px 16px;
    min-height: 44px;
    justify-content: center;
  }

  /* Add backdrop for mobile dropdown */
  .tag-dropdown-container::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 999;
  }

  .tag-dropdown-container:has(.tag-dropdown-panel.active)::before {
    opacity: 1;
    pointer-events: auto;
  }
}

/* No Content Placeholder */
.no-content-placeholder {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 500px;
  padding: 60px 20px;
  text-align: center;
  background: transparent;
  border-radius: 20px;
  margin: 40px auto;
  max-width: 800px;
  width: calc(100% - 8%);
  grid-column: 1 / -1;
}

.no-content-placeholder.active {
  display: flex;
}

.no-content-icon {
  margin-bottom: 30px;
  line-height: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: none;
  outline: none;
  padding-left: 75px;
}

.no-content-icon i {
  font-size: 80px;
  color: rgba(0, 140, 255, 0.3);
  animation: pulse 2s ease-in-out infinite;
  background: none !important;
  background-color: transparent !important;
  outline: none !important;
  padding: 0;
  margin: 0;
  display: inline-block;
  width: auto;
  height: auto;
  text-align: center;
  box-shadow: none !important;
  border: none !important;
  text-shadow: none !important;
}

.no-content-icon i::before,
.no-content-icon i::after {
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  text-shadow: none !important;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.6;
  }
}

.no-content-title {
  font-size: 2rem;
  font-weight: 600;
  color: white;
  margin: 0 0 15px 0;
}

.no-content-message {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 30px 0;
  max-width: 500px;
}

.no-content-reset-btn {
  padding: 12px 30px;
  background-color: var(--primary-color);
  border: none;
  border-radius: 30px;
  color: white;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.no-content-reset-btn:hover {
  background-color: rgba(0, 140, 255, 0.8);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 140, 255, 0.4);
}

.no-content-reset-btn i {
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .no-content-placeholder {
    min-height: 400px;
    padding: 40px 20px;
    margin: 20px 2%;
  }

  .no-content-icon {
    font-size: 60px;
    margin-bottom: 20px;
  }

  .no-content-title {
    font-size: 1.5rem;
  }

  .no-content-message {
    font-size: 1rem;
  }

  .no-content-reset-btn {
    padding: 10px 24px;
    font-size: 0.9rem;
  }
}
