/* ==========================================================================
   COLOR VARIABLES
   ========================================================================== */
:root {
  /* Dark Mode (Default) */
  --bg-primary: #1c1c1c;
  --bg-secondary: #2a2a2a;
  --bg-tertiary: #222; /* Footer, Table Background */
  --bg-gradient-start: #2a2a2a;
  --bg-gradient-end: #1a1a1a;
  --text-primary: #e0e0e0;
  --text-secondary: #ccc;
  --text-heading: #fff;
  --text-disabled: #555;
  --border-primary: #444;
  --border-secondary: #383838;
  --accent-primary: #e44d26;
  --accent-primary-hover: #f55a35;
  --accent-primary-transparent: rgba(228, 77, 38, 0.3);
  --accent-border: rgba(228, 77, 38, 0.5);
  --accent-glow: rgba(228, 77, 38, 0.5);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --shadow-strong-color: rgba(0, 0, 0, 0.4);
  --shadow-text-color: rgba(0, 0, 0, 0.7);
  --card-border-light-trans: rgba(255, 255, 255, 0.1);
  --card-bg-trans: rgba(42, 42, 42, 0.7);
  --spinner-base: rgba(228, 77, 38, 0.2);
  --spinner-top: var(--accent-primary);
  --card-sheen-gradient: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0)
  );
  --bg-overlay-dark: rgba(0, 0, 0, 0.8);
  --element-bg-hover: #3a3a3a; /* Dark mode hover */

  /* Content Page Specific Variables */
  --code-bg: #2e2e2e;
  --code-border: #444;
  --scrollbar-track-bg: #2c2c2c;
  --scrollbar-thumb-bg: #555;
  --scrollbar-thumb-hover-bg: #777;
  --table-header-bg: #333;
  --table-row-hover-bg: #383838;
  --scroll-arrow-bg-trans: rgba(0, 0, 0, 0.5);
}

/* Light Mode Overrides */
body.light-mode {
  --bg-primary: #f4f4f4;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e0e0e0; /* Footer, Table Background */
  --bg-gradient-start: #ffffff;
  --bg-gradient-end: #f0f0f0;
  --text-primary: #333333;
  --text-secondary: #555555;
  --text-heading: #111111;
  --text-disabled: #aaaaaa;
  --border-primary: #cccccc;
  --border-secondary: #dddddd;
  /* Accents can often stay the same, or adjust slightly if needed */
  /* --accent-primary: #d8441f; */
  /* --accent-primary-hover: #e8502a; */
  --accent-primary-transparent: rgba(228, 77, 38, 0.15);
  --accent-border: rgba(228, 77, 38, 0.4);
  --accent-glow: rgba(228, 77, 38, 0.3);
  --shadow-color: rgba(0, 0, 0, 0.1);
  --shadow-strong-color: rgba(0, 0, 0, 0.15);
  --shadow-text-color: rgba(0, 0, 0, 0.2);
  --card-border-light-trans: rgba(0, 0, 0, 0.1);
  --card-bg-trans: rgba(255, 255, 255, 0.8);
  --spinner-base: rgba(228, 77, 38, 0.15);
  /* Spinner top can stay the same */
  --card-sheen-gradient: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.03),
    rgba(0, 0, 0, 0)
  ); /* Subtle dark sheen for light */
  --bg-overlay-dark: rgba(244, 244, 244, 0.85); /* Light overlay */
  --element-bg-hover: #e8e8e8; /* Light mode hover */

  /* Content Page Specific Variables - Light Mode */
  --code-bg: #f0f0f0;
  --code-border: #ddd;
  --scrollbar-track-bg: #f0f0f0;
  --scrollbar-thumb-bg: #ccc;
  --scrollbar-thumb-hover-bg: #bbb;
  --table-header-bg: #f0f0f0;
  --table-row-hover-bg: #f9f9f9;
  --scroll-arrow-bg-trans: rgba(255, 255, 255, 0.7);
}

/* ==========================================================================
     RESET & BASE STYLES
     ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0; /* Removed 0px as 0 is sufficient */
  background-color: var(--bg-primary); /* Use variable */
  color: var(--text-primary); /* Use variable */
  transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition */
}

/* ==========================================================================
     LAYOUT & CONTAINER
     ========================================================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px;
  align-items: center; /* This typically applies to flex containers, might be unused if .container is not display:flex */
}

/* ==========================================================================
     HEADER & NAVIGATION
     ========================================================================== */
.site-header {
  background: var(--bg-secondary); /* Use variable */
  padding: 6px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 4px var(--shadow-color); /* Use variable */
  transition: background-color 0.3s;
}

.header-container {
  width: 95%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-logo {
  display: block;
  padding: 2px 0;
}

.site-logo img {
  height: 50px;
  width: auto;
  display: block;
}

/* Navigation */
.main-nav {
  display: flex;
  align-items: center;
}

#nav-menu {
  display: flex;
  list-style: none;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.main-nav li {
  margin: 0;
  position: relative;
}

.main-nav a {
  color: var(--text-secondary); /* Use variable */
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  padding: 5px 12px;
  border-radius: 4px;
  position: relative;
  display: inline-block;
}

/* Create the pseudo-element for the underline */
.main-nav a::after {
  content: ""; /* Required for pseudo-elements */
  position: absolute; /* Position relative to the link */
  left: 0;
  bottom: 0; /* Position at the bottom */
  width: 100%; /* Make it the full width of the link */
  height: 2px; /* Set the thickness of the underline */
  background-color: var(--accent-primary); /* Use the accent color */
  transform: scaleX(0); /* Start with zero width (scaled down) */
  transform-origin: bottom left; /* Animate from the left */
  transition: transform 0.3s ease; /* Add a smooth transition effect */
}

/* Animate the underline on hover and for the active state */
.main-nav a:hover::after,
.main-nav a.active::after {
  transform: scaleX(1); /* Scale to full width */
}

.main-nav a:hover,
.main-nav a.active {
  color: white;
  background-color: transparent;
}

/* Dropdown styles */
.dropdown-toggle {
  display: flex;
  align-items: center;
}

.chevron-icon {
  margin-left: 6px;
  transition: transform 0.3s ease;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--bg-secondary); /* Use variable */
  min-width: 250px;
  box-shadow: 0 4px 8px var(--shadow-color); /* Use variable */
  border-radius: 4px;
  padding: 10px 0;
  margin: 0;
  list-style: none;
  opacity: 0;
  display: block;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s ease;
  z-index: 1001;
}

.dropdown-menu li {
  width: 100%;
  border-bottom: 1px solid var(--border-secondary); /* Use variable */
}

.dropdown-menu li:last-child {
  border-bottom: none;
}

.dropdown-menu a {
  padding: 12px 16px;
  display: block;
  width: 100%;
  color: var(--text-secondary); /* Use variable */
}

.dropdown-menu a:hover {
  background-color: var(--accent-primary-transparent); /* Use variable */
  color: var(--text-heading); /* Use variable */
}

/* Mobile menu button */
#mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 30px;
  height: 25px;
  position: relative;
  z-index: 2;
  margin-left: 10px;
}

#mobile-menu-toggle span {
  display: block;
  position: absolute;
  height: 3px;
  width: 100%;
  background: var(--text-secondary); /* Use variable */
  border-radius: 3px;
  opacity: 1;
  left: 0;
  transform: rotate(0deg);
  transition: 0.25s ease-in-out;
}

#mobile-menu-toggle span:nth-child(1) {
  top: 0px;
}

#mobile-menu-toggle span:nth-child(2) {
  top: 10px;
}

#mobile-menu-toggle span:nth-child(3) {
  top: 20px;
}

#mobile-menu-toggle.open span:nth-child(1) {
  top: 10px;
  transform: rotate(135deg);
}

#mobile-menu-toggle.open span:nth-child(2) {
  opacity: 0;
  left: -60px;
}

#mobile-menu-toggle.open span:nth-child(3) {
  top: 10px;
  transform: rotate(-135deg);
}

/* ==========================================================================
     TYPOGRAPHY
     ========================================================================== */
h1 {
  text-align: center;
  color: var(--text-heading); /* Use variable */
  margin-bottom: 30px;
  /* Note: Context-specific h1 styles are in .content-page and .wallpaper-info */
}

/* ==========================================================================
     FORMS & INPUTS (Search, Selectors)
     ========================================================================== */

/* App Selector (Top level, if used outside panel) */
.app-selector {
  margin-bottom: 40px;
  text-align: center;
}

.app-selector select {
  padding: 10px 15px;
  font-size: 16px;
  border-radius: 5px;
  border: 1px solid var(--border-primary); /* Use variable */
  min-width: 200px;
  background-color: var(--bg-secondary); /* Use variable */
  color: var(--text-primary); /* Use variable */
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

/* Search bar styles */
.search-container {
  margin-bottom: 40px;
  text-align: center;
  /* Note: .top-main-controls .search-container overrides margin-bottom */
}

.search-form {
  display: flex;
  margin: 0 auto;
  width: 100%;
}

.search-input {
  flex-grow: 1;
  padding: 10px 15px;
  font-size: 16px;
  border: 1px solid var(--border-primary); /* Use variable */
  border-radius: 5px 0 0 5px;
  outline: none;
  background-color: var(--bg-secondary); /* Use variable */
  color: var(--text-primary); /* Use variable */
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

.search-button {
  padding: 10px 20px;
  background-color: var(--accent-primary); /* Use variable */
  color: white;
  border: none;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
}

.search-button:hover {
  background-color: var(--accent-primary-hover); /* Use variable */
}

/* JQuery UI Autocomplete */
.ui-autocomplete {
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  background: var(--bg-secondary); /* Use variable */
  border: 1px solid #ddd; /* Consider var(--border-primary) */
  border-radius: 4px;
  box-shadow: 0 4px 8px var(--shadow-color); /* Use variable */
  padding: 5px 0;
  color: var(--text-primary);
}

.ui-autocomplete .ui-menu-item {
  padding: 5px 10px;
  cursor: pointer;
  font-size: 14px;
}

.ui-autocomplete .ui-menu-item:hover {
  background-color: var(--accent-primary); /* Use variable */
  color: white;
}

.ui-helper-hidden-accessible {
  display: none;
}

/* ==========================================================================
     FILTER CONTROLS (Categories, Tags - Legacy Buttons)
     ========================================================================== */
.horizontal-items {
  /* General utility for horizontal flex items, used by old selectors */
  display: flex;
  gap: 10px;
  justify-content: center;
}

.category-selector-container,
.tag-selector-container {
  margin-bottom: 40px;
  position: relative;
}

.category-selector,
.tag-selector {
  /* Container for legacy category/tag buttons */
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 100%;
}

.category-btn,
.tag-btn {
  /* Legacy category/tag button style */
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 20px;
  border: 1px solid var(--border-secondary); /* Use variable */
  background-color: var(--bg-secondary); /* Use variable */
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); /* Consider var(--shadow-color) */
  text-decoration: none;
  color: var(--text-secondary); /* Use variable */
}

.category-btn:hover,
.tag-btn:hover {
  background-color: var(--element-bg-hover, #3a3a3a);
  color: var(--text-heading);
}
body.light-mode .category-btn:hover,
body.light-mode .tag-btn:hover {
  background-color: var(--element-bg-hover, #e8e8e8);
  color: #000;
}

.category-btn.active,
.tag-btn.active {
  background-color: var(--accent-primary); /* Use variable */
  color: white;
  border-color: var(--accent-primary); /* Use variable */
}

body.light-mode .category-btn.active,
body.light-mode .tag-btn.active {
  color: white; /* Keep text white on active buttons in light mode */
}

/* Tag Show Button (Legacy) */
.tag-btn-show {
  /* Button to reveal tag container */
  background-color: var(--accent-primary); /* Use variable */
  color: white;
  border-color: var(--accent-primary); /* Use variable */
  margin-bottom: 15px;
  /* Inherits other .tag-btn styles if applied together */
}
body.light-mode .tag-btn-show {
  color: white;
}

/* Tag Container & Filter (Legacy) */
.tag-container {
  /* Collapsible container for legacy tags */
  margin-bottom: 20px;
  background-color: var(--bg-secondary); /* Use variable */
  border-radius: 10px;
  box-shadow: 0 4px 6px var(--shadow-strong-color); /* Use variable */
  padding: 15px;
  display: none; /* Initially hidden */
}

.tag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.tag-title {
  font-size: 16px;
  font-weight: bold;
  color: var(--text-heading); /* Use variable */
}

.tag-filter {
  /* Input to filter tags in legacy view */
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-primary); /* Use variable */
  width: 200px;
  font-size: 14px;
  background-color: var(--bg-secondary); /* Use variable */
  color: var(--text-primary); /* Use variable */
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

.tags-grid {
  /* Grid for legacy tags */
  max-height: 200px;
  overflow-y: auto;
  padding-right: 5px;
}

.tag-buttons-wrapper {
  /* Wrapper for tag buttons in legacy view */
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
}

.tag-letter-group {
  width: 100%;
  margin-bottom: 10px;
}

.tag-letter {
  font-weight: bold;
  margin-bottom: 5px;
  color: var(--accent-primary); /* Use variable */
  border-bottom: 1px solid var(--border-primary); /* Use variable */
}

/* ==========================================================================
     CATEGORY CAROUSEL (Horizontal Scroll)
     ========================================================================== */
.category-carousel-container {
  width: 100%;
  padding: 1.5rem 50px;
  margin-bottom: 1rem;
  background: linear-gradient(
    135deg,
    var(--bg-gradient-start),
    var(--bg-gradient-end)
  ); /* Use variables */
  box-shadow: 0 4px 15px var(--shadow-strong-color); /* Use variable */
  /*overflow: hidden;*/
  border-radius: 12px;
  position: relative;
  transition: background 0.3s;
}

.category-carousel {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 1rem 0;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  gap: 1.5rem;
}

.category-carousel::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

.category-card {
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border-radius: 12px;
  padding: 0.8rem;
  background: var(--card-bg-trans); /* Use variable */
  backdrop-filter: blur(5px);
  border: 1px solid var(--card-border-light-trans); /* Use variable */
  position: relative;
  overflow: hidden;
  /* Duplicated transition properties, simplified */
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease,
    border 0.3s ease;
}

.category-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--card-sheen-gradient); /* Use variable */
  border-radius: 12px; /* Match parent */
  z-index: -1; /* Ensure it's behind content */
}

.category-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px var(--shadow-strong-color); /* Use variable */
}

.category-card.active {
  background: var(--accent-primary-transparent); /* Use variable */
  box-shadow: 0 0 15px var(--accent-glow); /* Use variable */
  border: 1px solid var(--accent-border); /* Use variable */
}

.category-image-container {
  width: 100px;
  height: 100px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0.8rem;
  position: relative;
  box-shadow: 0 4px 8px var(--shadow-strong-color); /* Use variable */
}

.category-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.category-card:hover .category-image {
  transform: scale(1.1);
}

.category-name {
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  margin-top: 0.3rem;
  color: var(--text-heading); /* Use variable */
  text-shadow: 0 1px 2px var(--shadow-text-color); /* Use variable */
}

/* Alternative Horizontal Categories (Simpler, older version?) */
.horizontal-categories {
  position: relative;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px var(--shadow-color);
  display: flex;
  align-items: center;
}

.search-icon-container {
  /* Part of .horizontal-categories */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(
    255,
    255,
    255,
    0.2
  ); /* Hardcoded, consider variables if themeable */
  border-radius: 50%;
  width: 40px;
  height: 40px;
  margin-right: 15px;
  flex-shrink: 0;
  transition: all 0.3s ease;
  cursor: pointer;
}

.search-icon-container:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.search-icon {
  /* Icon within .search-icon-container */
  color: white; /* Hardcoded, consider var(--text-heading) */
  font-size: 20px;
}

.categories-scroll {
  /* Scroller within .horizontal-categories */
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
  padding: 5px 0;
  flex-grow: 1;
}

.categories-scroll::-webkit-scrollbar {
  display: none;
}

.category-scroll-item {
  /* Item within .categories-scroll */
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.15); /* Hardcoded */
  border-radius: 20px;
  margin-right: 10px;
  white-space: nowrap;
  color: white; /* Hardcoded */
  font-weight: 500;
  transition: all 0.3s ease;
  text-decoration: none;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1); /* Hardcoded */
}

.category-scroll-item:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.category-scroll-item.active {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.category-icon {
  /* Icon within .category-scroll-item */
  margin-right: 6px;
  font-size: 14px;
}

.scroll-arrow {
  /* Arrows for .horizontal-categories and cat-horizontal-categories-panel */
  width: 40px;
  height: 40px;
  background: var(--scroll-arrow-bg-trans);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  opacity: 0.7;
  flex-shrink: 0;
  margin: 0 5px;
}

.scroll-arrow:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7); /* Consider a variable */
}

/* NEW ARROW STYLES FOR MAIN CAROUSEL */
.category-carousel-container > .carousel-arrow {
  /* Target direct children */
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background-color: var(--scroll-arrow-bg-trans, rgba(0, 0, 0, 0.5));
  color: var(--text-heading, #fff);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background-color 0.3s, opacity 0.3s;
  opacity: 0.7;
}

.category-carousel-container > .carousel-arrow:hover {
  background-color: var(--accent-primary, #e44d26);
  opacity: 1;
}

.category-carousel-container > .carousel-arrow.disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

.category-carousel-container > .carousel-arrow-left {
  left: 5px;
}

.category-carousel-container > .carousel-arrow-right {
  right: 5px;
}

/* ==========================================================================
     ADVANCED FILTER UI (Top Controls & Collapsible Panel)
     ========================================================================== */

/* --- Top Main Controls Bar --- */
.top-main-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  padding: 10px 0;
}

/* ADD THIS MEDIA QUERY FOR MOBILE STACKING */
@media (max-width: 767px) {
  /* Adjust breakpoint as needed (767px is common for tablets/phones) */
  .top-main-controls {
    flex-direction: column; /* Stack them vertically */
    align-items: stretch; /* Make children take full width of the column */
  }

  .top-main-controls .search-container {
    margin-bottom: 15px; /* Add some space below search when stacked */
    /* flex-grow: 0; /* Reset flex-grow if it was set for row layout */
    /* width: 100%; /* Ensure it takes full width, though align-items: stretch on parent should do this */
  }

  .main-filter-toggle-and-counter {
    /* margin-left: 0; /* Reset any left margin if it was set for row layout */
    /* width: 100%; /* Optional: make it full width if desired, or let it size to content */
    justify-content: space-between; /* Ensure button and counter are still spaced if not full width */
  }
}

.top-main-controls .search-container {
  /* Override for search within this bar */
  flex-grow: 1;
  margin-bottom: 0;
}

.main-filter-toggle-and-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow-color) 0px 1px 3px;
  flex-shrink: 0;
}

.filter-toggle-btn {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  background-color: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.filter-toggle-btn:hover {
  background-color: var(--accent-primary-hover);
}
.filter-toggle-btn:active {
  transform: scale(0.97);
}
.filter-toggle-btn .fas {
  /* Assuming FontAwesome icon */
  font-size: 0.8em;
}

.wallpaper-counter {
  /* Counter display */
  font-size: 16px; /* Maintained from one definition */
  font-weight: 600; /* Maintained */
  color: var(--text-secondary);
  padding: 8px 16px; /* Maintained from one definition */
  /* Other definition: font-size: 0.9rem; - choosing 16px as it's more specific */
}
.wallpaper-counter #counter, /* For specific counter ID */
  .wallpaper-counter #siteCounter {
  /* For specific counter ID */
  font-weight: 700; /* Maintained from #counter */
  color: var(--accent-primary);
}

.counter-container {
  /* General container for counter, if used */
  display: flex;
  align-items: center;
  gap: 15px;
}

/* --- Active Filter Info Bar --- */
.filter-info {
  /* Old filter info bar - can be merged or deprecated if new one replaces it */
  text-align: center;
  margin-bottom: 20px;
  padding: 10px;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 8px;
  display: none; /* Initially hidden */
}
.filter-info .filter-pill {
  /* Pills for old filter info */
  display: inline-block;
  padding: 5px 10px;
  margin: 5px;
  background-color: var(--accent-primary);
  color: white;
  border-radius: 20px;
  font-size: 14px;
}
.filter-info .clear-filter {
  /* Link to clear old filters */
  color: var(--accent-primary);
  text-decoration: none;
  margin-left: 10px;
  font-weight: bold;
}

.filter-info-active {
  /* New active filter info bar */
  display: flex; /* Initially shown, controlled by JS */
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 15px;
  margin-bottom: 20px;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-secondary);
}
.filter-info-active .filter-info-label {
  font-weight: 600;
  color: var(--text-heading);
  margin-right: 5px;
  flex-shrink: 0;
}
.filter-info-active .filter-pill {
  /* Pills for new active filter info */
  background-color: var(--accent-primary);
  color: white;
  padding: 4px 10px;
  border-radius: 15px;
  font-size: 0.85rem;
}
.filter-info-active .clear-active-filters-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9em;
  margin-left: auto; /* Pushes to the right */
}
.filter-info-active .clear-active-filters-link:hover {
  text-decoration: underline;
}

/* --- Collapsible Filter Panel --- */
.collapsible-filter-panel {
  background-color: var(--bg-tertiary);
  border-radius: 10px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); /* Consider var(--shadow-strong-color) */
  border: 1px solid var(--border-primary);
  /* display: none; /* Should be controlled by JS */
}
.filter-panel-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-secondary);
}
.filter-panel-section:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.filter-panel-section h4 {
  font-size: 1.15rem;
  color: var(--text-heading);
  margin-top: 0;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-primary);
  font-weight: 500;
}

/* App Selector in Panel */
.app-selector-panel select#appSelectPanel {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border-radius: 5px;
  border: 1px solid var(--border-primary);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  box-sizing: border-box;
  cursor: pointer;
}
.app-selector-panel select#appSelectPanel:hover {
  border-color: var(--accent-border); /* Using a defined accent border color */
}

/* Device Type Selector in Panel */
.device-type-selector-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.panel-category-btn {
  /* Specific class for device buttons in panel */
  padding: 7px 14px;
  font-size: 0.85rem;
  border-radius: 18px;
  border: 1px solid var(--border-secondary);
  background-color: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* Consider var(--shadow-color) */
}
.panel-category-btn:hover {
  background-color: var(--element-bg-hover);
  color: var(--text-heading);
}
.panel-category-btn.active {
  background-color: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  box-shadow: 0 0 5px var(--accent-glow);
}

/* Tag Container in Panel */
.tag-container-panel {
  /* Assuming this is a wrapper class if needed */
  margin-top: 0; /* Example, specific to panel if different from generic .tag-container */
}
.tag-header-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.tag-title-panel {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-heading);
}
.tag-filter-input-panel {
  /* Renamed for clarity (was tag-filter) */
  padding: 7px 10px;
  border-radius: 18px;
  border: 1px solid var(--border-primary);
  width: 220px;
  font-size: 0.9rem;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}
.tags-grid-panel {
  /* Renamed for clarity */
  max-height: 280px;
  overflow-y: auto;
  padding-right: 5px;
}
.tag-letter-group-panel {
  /* Renamed for clarity */
  margin-bottom: 10px;
}
.tag-letter-panel {
  /* Renamed for clarity */
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--accent-primary);
  border-bottom: 1px solid var(--border-primary);
  font-size: 0.9rem;
}
.tag-buttons-wrapper-panel {
  /* Renamed for clarity */
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 5px;
}
.panel-tag-btn {
  /* Specific class for tag buttons in panel */
  padding: 5px 10px;
  font-size: 0.85rem;
  border-radius: 15px;
  border: 1px solid var(--border-secondary);
  background-color: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--text-secondary);
}
.panel-tag-btn:hover {
  background-color: var(--element-bg-hover);
  color: var(--text-heading);
}
.panel-tag-btn.active {
  background-color: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* Theme Scroller in Panel */
.cat-horizontal-categories-panel {
  position: relative;
  display: flex;
  align-items: center;
  background: transparent; /* Different from main .horizontal-categories */
  padding: 10px 0;
}
.cat-categories-scroll-panel {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-grow: 1;
  padding: 5px 0;
}
.cat-categories-scroll-panel::-webkit-scrollbar {
  display: none;
}
.panel-theme-item {
  /* Specific class for theme items in panel */
  padding: 7px 14px;
  background: var(--bg-secondary);
  border-radius: 18px;
  margin-right: 10px;
  white-space: nowrap;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  text-decoration: none;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-primary);
}
.panel-theme-item:hover {
  background: var(--element-bg-hover);
  color: var(--text-heading);
}
.panel-theme-item.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}
.panel-theme-icon {
  margin-right: 6px;
  font-size: 0.9em;
}
.cat-scroll-arrow-panel {
  /* Specific class for arrows in panel's theme scroller */
  width: 35px;
  height: 35px;
  background: rgba(
    0,
    0,
    0,
    0.2
  ); /* Hardcoded, consider var(--scroll-arrow-bg-trans) with different opacity */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  z-index: 5;
  transition: all 0.2s ease;
  opacity: 0.6;
  flex-shrink: 0;
  margin: 0 5px;
}
.cat-scroll-arrow-panel:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.4);
}

/* Panel Actions / Clear Button */
.filter-panel-actions {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid var(--border-secondary);
  text-align: center;
}
.clear-panel-filters-button {
  padding: 9px 22px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid var(--accent-border);
  background-color: transparent;
  color: var(--accent-primary);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.clear-panel-filters-button:hover {
  background-color: var(--accent-primary-transparent);
  color: var(--accent-primary-hover);
}

/* ==========================================================================
     WALLPAPER GALLERY & ITEMS
     ========================================================================== */
.gallery-image {
  /* Small preview image, distinct from wallpaper-image on detail page */
  width: 100px;
  height: auto;
  display: block;
  margin: 10px auto;
  transition: all 0.3s ease;
}

.gallery-image:hover {
  transform: scale(1.05);
  opacity: 0.9;
  cursor: pointer;
}

.wallpaper-grid {
  position: relative; /* ESSENTIAL for Masonry item positioning */
  margin-bottom: 0; /* Adjusted as pagination is removed, loading indicator follows */
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
}

.wallpaper-item {
  position: relative; /* Keeps premium badge positioning relative to item */
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 8px var(--shadow-color);
  background-color: var(--bg-secondary);
  opacity: 0;
  transition: opacity 0.4s ease-in, transform 0.3s ease; /* transform is for existing hover */
}

.wallpaper-item:hover {
  transform: translateY(-5px); /* Existing hover effect */
}

.wallpaper-item.is-loaded {
  opacity: 1;
}

.wallpaper-img {
  display: block; /* Important for imagesLoaded and layout */
  width: 100%;
  height: 100%; /* If aspect-ratio is on parent, or let natural height flow */
  object-fit: cover;
}

.wallpaper-link {
  display: block;
  width: 100%;
  height: 100%;
}

/* Device-specific aspect ratios and styles */
.desktop-item {
  aspect-ratio: 16/9;
}
.tv-item {
  aspect-ratio: 16/9;
}
.watch-item {
  aspect-ratio: 1/1;
  border-radius: 20px;
}
.watch-circular-item {
  aspect-ratio: 1/1;
  border-radius: 50%;
}
.tablet-item {
  aspect-ratio: 4/3;
}

.premium-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: var(--accent-primary);
  color: white;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  z-index: 1; /* Ensure it's above the image */
}

.no-wallpapers {
  /* Ensure this still works if grid is empty. Masonry won't initialize. */
  width: 100%; /* Take full width of the container */
  text-align: center;
  padding: 50px;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 10px;
}

/* Default (Desktop - 5 columns) */
@media (min-width: 1101px) {
  .wallpaper-item {
    width: calc(
      (100% - 4 * 10px) / 5
    ); /* 10px is the gutter value used in JS */
    margin-bottom: 10px; /* This becomes the vertical gutter for Masonry */
  }
}

/* Smaller Desktop / Large Tablet - 4 columns */
@media (max-width: 1100px) and (min-width: 901px) {
  .wallpaper-item {
    width: calc((100% - 3 * 10px) / 4);
    margin-bottom: 10px;
  }
}

/* Tablet - 3 columns */
@media (max-width: 900px) and (min-width: 601px) {
  .wallpaper-item {
    width: calc((100% - 2 * 10px) / 3);
    margin-bottom: 10px;
  }
}

/* Mobile - 2 columns */
@media (max-width: 600px) {
  .wallpaper-item {
    width: calc((100% - 1 * 10px) / 2);
    margin-bottom: 10px;
  }
}

/* ==========================================================================
     LOADING INDICATOR & ANIMATIONS
     ========================================================================== */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 30px 0;
  padding: 20px;
  width: 100%; /* Takes full width of its container */
  color: var(--text-primary); /* Use variable */
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--spinner-base); /* Use variable */
  border-top-color: var(--spinner-top); /* Use variable */
  animation: spin 1s infinite linear;
  margin-bottom: 15px;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
     WALLPAPER DETAILS PAGE
     ========================================================================== */
.header {
  /* General header class, might conflict if not specific to details page */
  /* Assuming this is for the details page header structure, not site-header */
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.back-btn {
  padding: 10px 15px;
  background-color: var(--bg-secondary);
  border-radius: 5px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: bold;
  box-shadow: 0 2px 4px var(--shadow-color);
  display: inline-block;
  transition: background-color 0.3s;
}

.back-arrow {
  display: inline-block;
  vertical-align: middle;
  font-size: 16px;
  margin-right: 6px;
  transform: translateY(-2px);
}

.back-text {
  display: inline-block;
  vertical-align: middle;
}

.back-btn:hover {
  background-color: var(--element-bg-hover);
}

/* Breadcrumbs styling */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 20px;
  font-size: 14px;
  background-color: var(--bg-secondary);
  padding: 10px 15px;
  border-radius: 5px;
  box-shadow: 0 2px 4px var(--shadow-color);
}

.breadcrumbs a {
  color: var(--accent-primary);
  text-decoration: none;
  margin: 0 5px;
}

.breadcrumbs a:first-child {
  margin-left: 0;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.breadcrumbs .separator {
  margin: 0 5px;
  color: var(--text-disabled);
}

.breadcrumbs .current {
  color: var(--text-secondary);
  font-weight: 500;
}

.wallpaper-details {
  /* Main flex container for image and info */
  display: flex;
  gap: 30px;
  margin-bottom: 40px;
}

.wallpaper-image {
  /* Container for the large image on details page */
  flex: 1;
  background-color: var(--bg-secondary);
  border-radius: 10px;
  box-shadow: 0 4px 8px var(--shadow-color);
  padding: 20px;
  text-align: center;
}

.wallpaper-image img {
  /* The actual large image */
  max-width: 100%;
  max-height: 70vh;
  border-radius: 5px;
}

.wallpaper-info {
  /* Container for text info, buttons on details page */
  flex: 0 0 400px; /* Fixed width for info column */
  box-sizing: border-box;
  overflow: visible; /* Or auto/scroll if content can exceed */
  flex-shrink: 0;
  background-color: var(--bg-secondary);
  border-radius: 10px;
  box-shadow: 0 4px 8px var(--shadow-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.wallpaper-info h1 {
  /* Specific h1 for details page title */
  margin-top: 0;
  font-size: 24px;
  margin-bottom: 20px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  color: var(--text-heading);
  text-align: left; /* Overrides general h1 center align */
}

.info-row {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
}

.info-label {
  font-weight: bold;
  margin-right: 15px;
  color: var(--text-secondary);
}

.app-value {
  /* For displaying app name or similar info */
  font-size: 16px;
  color: var(--text-primary);
}

.download-btn {
  display: block;
  width: calc(100% - 30px); /* Adjust if padding/margins change */
  max-width: 100%;
  padding: 15px;
  background-color: var(--accent-primary); /* Original: #e44d26 */
  color: white;
  text-align: center;
  text-decoration: none;
  border-radius: 5px;
  font-weight: bold;
  margin-top: 25px;
  font-size: 16px;
  transition: background-color 0.3s;
}

.download-btn:hover {
  background-color: var(--accent-primary-hover); /* Original: #f55a35 */
}

.wallpaper-linked-description {
  margin-bottom: 15px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.wallpaper-linked-description a {
  color: var(--accent-primary);
  text-decoration: underline;
}

.wallpaper-linked-description a:hover {
  color: var(--accent-primary-hover);
}

.category-tags {
  /* Container for tags on details page */
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-tag {
  /* Individual tag/category pill on details page */
  background-color: var(--bg-tertiary);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background-color 0.3s, color 0.3s;
  white-space: nowrap;
  flex-shrink: 0;
}
.category-tags a.category-tag {
  /* Make tags linkable */
  text-decoration: none;
}
.category-tags a.category-tag:hover {
  background-color: var(--accent-primary);
  color: white;
}

/* Share Buttons */
.share-section {
  margin-top: 20px;
}

.share-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: white;
  text-decoration: none;
  transition: opacity 0.3s;
}

.share-btn:hover {
  opacity: 0.8;
}

.share-btn i {
  /* Assuming FontAwesome or similar icon library */
  font-size: 18px;
}

.share-facebook {
  background-color: #1877f2;
}
.share-twitter {
  background-color: #1da1f2;
}
.share-pinterest {
  background-color: #e60023;
}
.share-whatsapp {
  background-color: #25d366;
}

.copy-link-btn {
  display: flex;
  align-items: center;
  padding: 8px 15px;
  background-color: var(--bg-tertiary);
  border-radius: 20px;
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s;
}
.copy-link-btn:hover {
  background-color: var(--element-bg-hover);
}
.copy-link-btn i {
  margin-right: 5px;
}

/* Get App Button (e.g., for mobile app promo) */
.get-app-container {
  margin-top: 10px;
}
.get-app-btn {
  display: flex;
  align-items: center;
  padding: 8px 15px;
  background-color: var(--bg-secondary);
  border-radius: 5px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: bold;
  box-shadow: 0 2px 4px var(--shadow-color);
  transition: background-color 0.3s;
  max-width: fit-content;
}
.get-app-btn:hover {
  background-color: var(--element-bg-hover);
}
.get-app-btn img {
  /* For app store badge or icon */
  margin-right: 8px;
}

/* Related Wallpapers Section */
.related-section {
  margin-top: 40px;
}

.related-section h2 {
  margin-bottom: 20px;
  font-size: 22px;
  color: var(--text-heading);
}

.related-wallpapers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.related-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 8px var(--shadow-color);
  background-color: var(--bg-secondary);
  transition: transform 0.3s ease;
  aspect-ratio: 9/16; /* Match main wallpaper items */
}

.related-item:hover {
  transform: translateY(-5px);
}

.related-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.related-link {
  display: block;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
     CONTENT PAGES (About, Terms, Privacy, etc.)
     ========================================================================== */
.content-page {
  padding: 40px 20px 60px;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 2px 15px var(--shadow-strong-color);
  margin: 30px auto; /* Assuming .container sets max-width */
  animation: fadeIn 0.5s ease-out;
}

.content-page h1 {
  font-size: 32px;
  color: var(--text-heading);
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--border-primary);
  text-align: left; /* Override general h1 center */
}

.content-page h2 {
  font-size: 22px;
  color: var(--accent-primary);
  margin: 35px 0 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-secondary);
}

.content-page p {
  margin-bottom: 20px;
  color: var(--text-primary);
  line-height: 1.6;
}

.content-page strong {
  color: var(--text-heading);
}

.content-page ul {
  margin: 20px 0;
  padding-left: 25px;
  list-style-type: square;
}

.content-page ul li {
  margin-bottom: 10px;
  position: relative; /* For potential custom bullets */
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Date display (e.g., for blog posts or last updated) */
p strong + time, /* For <time> element after <strong> */
  p:first-of-type strong {
  /* If date is in first <p> with <strong>, e.g., "Last Updated: " */
  color: var(--text-secondary);
  font-style: italic;
}

/* Code blocks and technical elements */
code,
pre {
  background-color: var(--code-bg);
  border-radius: 4px;
  padding: 2px 5px;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  color: var(--text-primary);
  border: 1px solid var(--code-border);
  font-size: 0.9em;
}

pre {
  padding: 15px;
  overflow-x: auto;
  margin: 20px 0;
  line-height: 1.5;
}

/* Tables in Content Pages */
.content-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background-color: var(--bg-tertiary);
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid var(--border-primary);
}

.content-page th {
  background-color: var(--table-header-bg);
  color: var(--text-heading);
  font-weight: 600;
  border-bottom: 2px solid var(--border-primary);
}

.content-page th,
.content-page td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-secondary);
  text-align: left;
}

.content-page tr:last-child td {
  border-bottom: none;
}

.content-page tr:hover {
  background-color: var(--table-row-hover-bg);
}

/* ==========================================================================
     FOOTER
     ========================================================================== */
footer {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border-top: 1px solid var(--border-secondary);
  padding: 40px 20px;
  margin-top: 30px;
  margin-bottom: 50px;
  text-align: center;
  font-size: 0.9em;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.footer-container {
  max-width: 1200px; /* Match main container */
  margin: 0 auto;
  padding: 0 15px;
}

footer p {
  margin: 6px 0;
}

footer a {
  color: var(--accent-primary);
  text-decoration: none;
  margin: 0 5px;
}

footer a:hover {
  text-decoration: underline;
}

.footer-separator {
  margin: 0 5px;
  color: var(--border-primary);
}

/* ==========================================================================
     UTILITY COMPONENTS
     ========================================================================== */

/* --- Theme Toggle Button --- */
.theme-toggle-button {
  /* position: fixed; bottom: 20px; right: 20px; /* If fixed positioning is desired */
  /* Currently styled for inline use e.g. in header */
  padding: 8px 14px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: 50px;
  cursor: pointer;
  z-index: 1000; /* Ensure visibility if fixed */
  box-shadow: 0 2px 5px var(--shadow-color);
  transition: background-color 0.3s, color 0.3s, border-color 0.3s,
    box-shadow 0.3s;
  font-size: 14px;
  margin-right: 16px;
  margin-left: 16px;
}

.theme-toggle-button:hover {
  background-color: var(--element-bg-hover, #3a3a3a);
  color: var(--text-heading);
}
body.light-mode .theme-toggle-button:hover {
  background-color: var(--element-bg-hover, #e8e8e8);
  color: #000;
}

/* --- Social Sidebar --- */
.social-sidebar {
  position: fixed;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 1000;
}

.social-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 2px 4px var(--shadow-color);
  text-decoration: none;
  transition: all 0.3s ease;
}

.social-icon:hover {
  background-color: var(--accent-primary);
  color: white; /* Ensure contrast on accent background */
  transform: scale(1.1);
}

/* --- Toast Notification --- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-tertiary);
  color: var(--text-heading);
  padding: 10px 20px;
  border-radius: 5px;
  box-shadow: 0 2px 10px var(--shadow-strong-color);
  z-index: 10000; /* High z-index for visibility */
  display: none; /* Controlled by JS */
  transition: background-color 0.3s, color 0.3s, box-shadow 0.3s, opacity 0.3s,
    transform 0.3s;
}

/* ==========================================================================
     CUSTOM SCROLLBAR
     ========================================================================== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb-bg);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover-bg);
}

/* ==========================================================================
     RESPONSIVE STYLES
     ========================================================================== */

/* --- General Layout & Wallpaper Grid --- */
@media (max-width: 1100px) {
  .wallpaper-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  .wallpaper-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .wallpaper-details {
    /* Wallpaper Details Page */
    flex-direction: column;
  }
  .wallpaper-info {
    /* Wallpaper Details Page */
    flex: 1; /* Allow to take full width when stacked */
    flex-basis: auto; /* Reset fixed basis */
  }
  .related-wallpapers {
    /* Wallpaper Details Page */
    grid-template-columns: repeat(2, 1fr);
  }
  .breadcrumbs {
    /* Wallpaper Details Page */
    font-size: 12px;
  }
}

/* --- Mobile Specific (General) --- */
@media (max-width: 768px) {
  .category-carousel-container {
    /* ADD this */
    padding-left: 40px;
    padding-right: 40px;
  }
  .category-carousel-container > .carousel-arrow {
    /* ADD this */
    width: 35px;
    height: 35px;
  }
  .category-carousel-container > .carousel-arrow-left {
    /* ADD this */
    left: 3px;
  }
  .category-carousel-container > .carousel-arrow-right {
    /* ADD this */
    right: 3px;
  }
  .header-container {
    position: relative; /* For mobile menu positioning */
    padding: 0 15px; /* Adjust padding for mobile */
  }

  #mobile-menu-toggle {
    display: block; /* Show hamburger icon */
  }

  .main-nav {
    order: 3; /* Ensure nav is after logo/toggle */
    margin-left: auto; /* Push toggle to right */
  }

  #nav-menu {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%; /* Below header */
    right: 0;
    left: 0;
    background-color: var(--bg-secondary);
    flex-direction: column;
    padding: 10px 20px;
    gap: 0; /* Reset gap for vertical items */
    box-shadow: 0 4px 8px var(--shadow-color);
    z-index: 100; /* Below sticky header but above content */
  }
  #nav-menu.open {
    display: flex; /* Show when active */
  }
  .main-nav li {
    width: 100%;
    border-bottom: 1px solid var(--border-secondary);
  }
  .main-nav li:last-child {
    border-bottom: none;
  }
  .main-nav a {
    display: block; /* Full width links */
    padding: 12px 8px;
    width: 100%;
  }

  /* Mobile Dropdown Behavior */
  .dropdown-menu {
    position: static; /* No absolute positioning */
    width: 100%;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin-top: 0;
    display: none; /* Controlled by JS click/active class */
    opacity: 1; /* Ensure visible when display:block */
    visibility: visible;
    transform: none;
  }
  .dropdown-menu li {
    padding-left: 20px; /* Indent sub-menu items */
    border-top: 1px solid var(--border-secondary);
    border-bottom: none;
  }
  .dropdown.active .dropdown-menu {
    /* Show dropdown when parent .dropdown is active */
    display: block;
  }
  .dropdown.active .chevron-icon {
    transform: rotate(180deg);
  }

  /* Desktop Dropdown Hover Behavior (Ensure it only applies to desktop) */
  @media (min-width: 769px) {
    .dropdown:hover .dropdown-menu {
      opacity: 1;
      visibility: visible;
      transform: translateY(0);
      pointer-events: auto;
      transition-delay: 0s;
    }
    .dropdown:hover .chevron-icon {
      transform: rotate(180deg);
    }
  }

  /* Category Carousel on Mobile */
  .category-carousel {
    padding: 0.8rem 0;
    gap: 1rem;
  }
  .category-card {
    min-width: 110px;
  }
  .category-image-container {
    width: 80px;
    height: 80px;
  }
  .category-name {
    font-size: 0.8rem;
  }

  /* Social Sidebar on Mobile */
  .social-sidebar {
    position: fixed; /* Keep fixed */
    left: 0;
    top: auto; /* Remove top positioning */
    bottom: 0; /* Stick to bottom */
    transform: none; /* Reset transform */
    flex-direction: row; /* Horizontal layout */
    width: 100%;
    background-color: var(
      --bg-overlay-dark
    ); /* Darker overlay for visibility */
    padding: 10px 0;
    justify-content: center;
    gap: 15px; /* Adjust gap for horizontal layout */
  }
  .social-sidebar .social-icon {
    margin: 0 10px; /* Spacing between icons */
  }

  /* Top Main Controls on Mobile */
  /* Default is column, .top-main-controls @media (min-width: 768px) handles row */
}

@media (max-width: 600px) {
  .wallpaper-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Legacy Category/Tag Selectors Scroll on Mobile */
  .category-selector,
  .tag-selector {
    flex-wrap: nowrap; /* Prevent wrapping */
    overflow-x: auto; /* Enable horizontal scroll */
    justify-content: flex-start; /* Align items to start */
    padding-bottom: 10px; /* Space for scrollbar if visible */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: none; /* Hide scrollbar Firefox */
    -ms-overflow-style: none; /* Hide scrollbar IE/Edge */
  }
  .category-selector::-webkit-scrollbar,
  .tag-selector::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari/Opera */
  }
  .category-btn,
  .tag-btn {
    /* Ensure buttons don't shrink in scroll container */
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Search Form Stack on Mobile */
  .search-form {
    flex-direction: column;
  }
  .search-input {
    border-radius: 5px; /* Full radius when stacked */
    margin-bottom: 10px;
  }
  .search-button {
    border-radius: 5px; /* Full radius when stacked */
  }

  /* Footer on Small Screens */
  footer {
    font-size: 0.8em;
  }
  footer p span,
  footer p a {
    margin: 5px 5px;
  }
  .footer-separator {
    margin: 0 5px;
    color: var(--border-primary);
  }
}

/* ==========================================================================
     PRINT STYLES
     ========================================================================== */
@media print {
  header,
    footer,
    .site-header, /* Explicitly hide site header */
    .main-nav #mobile-menu-toggle, /* Hide mobile menu toggle */
    .theme-toggle-button,
    .social-sidebar,
    .filter-toggle-btn, /* Hide filter UI elements */
    .collapsible-filter-panel,
    .back-btn, /* Hide navigation buttons */
    .share-section, /* Hide share buttons */
    .download-btn, /* Hide download buttons */
    .get-app-btn,
    .scroll-arrow, /* Hide scroll arrows */
    .search-icon-container {
    display: none !important; /* Important to override other display properties */
  }

  body {
    background-color: white !important;
    color: black !important;
    font-size: 12pt;
    font-family: "Times New Roman", Times, serif;
    transition: none !important; /* Disable transitions */
  }

  .container,
    .content-page,
    .wallpaper-details, /* Ensure main content areas are styled for print */
    .wallpaper-info,
    .wallpaper-image {
    width: 100% !important;
    max-width: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: white !important;
    color: black !important;
    border-radius: 0 !important;
    border: none !important;
  }

  .content-page h1,
    .content-page h2,
    .content-page strong,
    .wallpaper-info h1, /* Titles on details page */
    .related-section h2 {
    color: black !important;
    border-color: #ccc !important; /* Lighter border */
  }

  .content-page p,
    .content-page li,
    .wallpaper-info p, /* Text on details page */
    .info-label,
    .app-value,
    .wallpaper-linked-description {
    color: #333 !important; /* Dark grey for readability */
  }

  a {
    color: #000 !important;
    text-decoration: underline !important;
  }
  a[href^="http"]:after {
    /* Show full URLs for external links */
    content: " (" attr(href) ")";
    font-size: 0.9em;
  }
  a[href^="/"]:after,
  a[href^="#"]:after {
    /* Don't show for internal/fragment links */
    content: "";
  }

  code,
  pre,
  .content-page table,
  .content-page th,
  .content-page td {
    background-color: #f8f8f8 !important;
    color: black !important;
    border: 1px solid #ddd !important;
  }

  img,
    .wallpaper-img, /* Ensure images are handled well */
    .related-img,
    .category-image,
    .wallpaper-image img {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid;
    border-radius: 0 !important; /* Remove rounded corners for print consistency */
  }

  .premium-badge, /* Hide non-essential visual elements */
    .category-tag,
    .breadcrumbs {
    display: none !important;
  }

  .wallpaper-grid,
  .related-wallpapers {
    display: block !important; /* Change grid to block for simpler printing */
  }
  .wallpaper-item,
  .related-item {
    page-break-inside: avoid;
    margin-bottom: 20px; /* Add some space between items when stacked */
    box-shadow: none !important;
    border: 1px solid #eee !important; /* Light border for separation */
  }
}

.cat-wallpaper-grid {
  position: relative;
  opacity: 0;
  transition: opacity 0.4s ease-in;
}

.cat-wallpaper-grid.is-visible {
  opacity: 1;
}

.cat-wallpaper-item {
  opacity: 0;
  transition: opacity 0.4s ease-in;
}

.cat-wallpaper-item.is-loaded {
  opacity: 1;
}

/* Styles for Buy Me a Coffee Modal */
.bmc-modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1050; /* Sit on top, higher than most elements */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto; /* Enable scroll if needed */
  background-color: rgba(0, 0, 0, 0.6); /* Dim background */
  padding-top: 50px;
}

.bmc-modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 25px;
  border: 1px solid #ddd;
  width: 90%;
  max-width: 500px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  animation: bmcModalAppear 0.3s ease-out;
}

@keyframes bmcModalAppear {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.bmc-modal-content h2 {
  margin-top: 0;
  color: #333;
  font-size: 1.6em;
  margin-bottom: 15px;
}

.bmc-modal-content p {
  color: #555;
  line-height: 1.6;
  margin-bottom: 20px;
  font-size: 1em;
}

.bmc-close-modal-btn {
  background: none;
  border: none;
  color: #aaa;
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

.bmc-close-modal-btn:hover,
.bmc-close-modal-btn:focus {
  color: #333;
  text-decoration: none;
}

.bmc-button-link img {
  margin: 15px auto;
  display: block;
  border: 0 !important;
  box-shadow: none !important;
}

.bmc-modal-actions {
  margin-top: 25px;
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.bmc-modal-button {
  padding: 12px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  transition: background-color 0.2s ease, transform 0.1s ease;
  min-width: 160px; /* Ensure buttons have a decent size */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.bmc-modal-button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.bmc-skip-btn {
  background-color: #f0f0f0;
  color: #333;
  border: 1px solid #ccc;
}
.bmc-skip-btn:hover {
  background-color: #e0e0e0;
}

.bmc-support-btn {
  background-color: #ffdd00; /* BMC yellow */
  color: #000;
  border: 1px solid #e6c600;
}
.bmc-support-btn:hover {
  background-color: #f0c000;
}
