/* =============================================================================
   HEADER STYLES - Header, navigation, search, and filter components
   ============================================================================= */

/* Header Styles */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-primary);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Prevent horizontal overflow on mobile.
   Use `clip` (not `hidden`): `overflow-x: hidden` forces overflow-y to compute
   to `auto`, which turns the header into a vertical scroll container and both
   clips and scrolls open dropdowns (e.g. the language menu). `clip` avoids that. */
.header-container {
  overflow-x: hidden;
  overflow-x: clip;
  width: 100%;
}

/* Admin Header Override */
.header.admin-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .header.admin-header {
  background: linear-gradient(135deg, #4c1d95 0%, #581c87 100%);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
}

.admin-header .site-title a,
.admin-header .site-title span {
  color: white !important;
}

.admin-header .btn-icon {
  color: rgba(255, 255, 255, 0.8) !important;
}

.admin-header .btn-icon:hover:not(.disabled) {
  background-color: rgba(255, 255, 255, 0.1) !important;
  color: white !important;
}

.admin-header .btn-icon.active:not(.disabled) {
  background-color: rgba(255, 255, 255, 0.2) !important;
  color: white !important;
}

.admin-header .icon-separator {
  background: rgba(255, 255, 255, 0.3) !important;
}

.admin-header .logout-btn {
  background: rgba(220, 38, 38, 0.2) !important;
  border: 1px solid rgba(220, 38, 38, 0.3) !important;
  border-radius: 0.375rem !important;
}

.admin-header .logout-btn:hover {
  background: rgba(220, 38, 38, 0.3) !important;
  border-color: rgba(220, 38, 38, 0.5) !important;
  color: white !important;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.site-title a {
  text-decoration: none;
  color: var(--text-primary);
}

.site-logo {
  height: 2.5rem;
  width: auto;
  transition: opacity 0.2s;
}

.site-logo:hover {
  opacity: 0.8;
}

/* Theme-specific logo display */
.light-logo {
  display: block;
}

.dark-logo {
  display: none;
}

[data-theme="dark"] .light-logo {
  display: none;
}

[data-theme="dark"] .dark-logo {
  display: block;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Icon Groups - Clean spacing within groups */
.icon-group {
  display: flex;
  gap: 0.25rem;
}

/* Vertical Separators - Fixed thickness */
.icon-separator {
  width: 1px;
  height: 1.5rem;
  background: var(--border-secondary);
  margin: 0 0.5rem;
  transition: background-color 0.3s ease;
  flex-shrink: 0;
}

[data-theme="dark"] .icon-separator {
  background: var(--border-primary);
}

.btn-icon {
  position: relative;
  background: none;
  border: none;
  padding: 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg {
  width: 30px;
  height: 30px;
  stroke-width: 1;
  /* Applies to all icons except the lightbulb */
}

/* Site title lightbulb icon responsiveness */
.site-title svg {
  width: 50px;
  height: 50px;
  transition: all 0.3s ease;
}

.btn-icon:hover:not(.disabled) {
  background-color: var(--background-secondary);
  color: var(--text-primary);
}

.btn-icon.active:not(.disabled) {
  background-color: var(--accent-light);
  color: var(--accent-primary);
}

/* Disabled state for buttons with diagonal strikethrough */
.btn-icon.disabled {
  position: relative;
  cursor: not-allowed;
  color: #9ca3af;
  opacity: 0.6;
}

[data-theme="dark"] .btn-icon.disabled {
  color: #4b5563;
  opacity: 0.7;
}

.btn-icon.disabled::before {
  content: "";
  position: absolute;
  top: 15%;
  left: 15%;
  right: 15%;
  bottom: 15%;
  background: linear-gradient(to top right, transparent 48%, #6b7280 49%, #6b7280 51%, transparent 52%);
  pointer-events: none;
  z-index: 1;
}

[data-theme="dark"] .btn-icon.disabled::before {
  background: linear-gradient(to top right, transparent 48%, #374151 49%, #374151 51%, transparent 52%);
}

.btn-icon.disabled:hover {
  background-color: transparent;
}

.icon-group .btn-icon {
  padding: 0.625rem;
}

.badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--accent-primary);
  color: var(--bg-primary);
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  min-width: 1.25rem;
  text-align: center;
}

/* Theme Toggle */
.theme-toggle {
  position: relative;
}

.theme-toggle .moon-icon {
  display: block;
}

.theme-toggle .sun-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: block;
}

/* Search Bar */
.search-bar {
  display: none;
  padding: 1rem 0;
  border-top: 1px solid var(--border-primary);
  transition: border-color 0.3s ease;
}

.search-bar.active {
  display: block;
}

.search-input-group {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  padding: 0.75rem;
  gap: 0.75rem;
  transition: background-color 0.3s ease;
}

.search-input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 1rem;
  color: var(--text-primary);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

/* Filter Panel */
.filter-panel {
  display: none;
  padding: 0 0 1rem 0;
  margin-bottom: 1rem;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-primary);
  border-radius: 1rem;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.filter-panel.active {
  display: block;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.75rem;
}

.filter-header-title {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.filter-header h3 {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.filter-close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
  transition: color 0.15s, background-color 0.15s;
}

.filter-close-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

.tag-group {
  padding: 0.5rem 0.75rem 0.25rem;
  border-top: 1px solid var(--border-secondary);
}

.tag-group:first-of-type {
  border-top: none;
}

.tag-group-header {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  cursor: default;
}

.tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.35rem;
}

.tag-count {
  opacity: 0.65;
  font-size: 0.72em;
}

/* Filter panel hint */
.filter-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Filter footer — preview + action buttons */
.filter-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem 0.75rem;
  border-top: 1px solid var(--border-secondary);
  margin-top: 0.25rem;
}

.filter-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Live filter preview */
.filter-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.6rem;
  font-size: 0.78rem;
}

.fp-empty {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-style: italic;
}

.fp-group {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: 0.4rem;
  padding: 0.15rem 0.45rem;
}

.fp-group-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 0.1rem;
}

.fp-tag {
  font-size: 0.75rem;
  color: var(--text-primary);
  font-weight: 500;
}

.fp-and {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-primary);
  padding: 0 0.15rem;
}

.fp-or {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0 0.1rem;
}

/* button.tag — match the <a class="tag"> look */
button.tag {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border-secondary);
  outline: none;
}

/* Active Filters - Container for currently applied filters */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border-primary);
}

.active-filters-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.15rem;
}

/* Group chip wraps one group's label + tags */
.filter-group-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: 0.5rem;
  padding: 0.2rem 0.5rem;
}

.filter-group-chip-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 0.1rem;
}

/* "AND" between groups */
.filter-and-sep {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-primary);
  padding: 0 0.1rem;
}

/* "or" between tags within a group */
.filter-or-sep {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
}

.filter-label {
  font-weight: 500;
  color: var(--text-tertiary);
}

.remove-filter {
  font-weight: bold;
  margin-left: 0.25rem;
  color: inherit;
  text-decoration: none;
}

.remove-filter:hover {
  opacity: 0.7;
}

/* Admin Mode Styles */
.admin-indicator {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border-primary);
  margin-top: 0.5rem;
  background: var(--bg-secondary);
  border-radius: 0.5rem;
}

.admin-badge {
  display: inline-block;
  background: #ef4444;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-btn {
  position: relative;
}

.admin-btn::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 50%;
  border: 1px solid var(--bg-primary);
}

.admin-btn:hover {
  background-color: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.admin-logout-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: #dc2626;
  color: white;
  text-decoration: none;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.admin-logout-btn:hover {
  background: #b91c1c;
}

.admin-logout-btn svg {
  flex-shrink: 0;
}

[data-theme="dark"] .admin-btn:hover {
  background-color: rgba(239, 68, 68, 0.2);
}

/* Header Responsive Design */
@media (max-width: 768px) {
  .header-container {
    padding: 0 1rem;
  }

  .header-content {
    padding: 0.75rem 0;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .site-title {
    font-size: 1.25rem;
    flex: 1;
    min-width: 0; /* Allow shrinking */
  }

  /* Mobile-optimized site title styling */
  .site-title a {
    gap: 0.5rem !important;
    flex-wrap: nowrap;
    min-width: 0;
  }

  .site-title a span:first-child {
    padding-left: 0.5rem !important;
    padding-right: 0.25rem !important;
    flex-shrink: 0;
  }

  .site-title a span:last-child {
    font-size: 1.1rem !important;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* Lightbulb icon mobile sizing */
  .site-title svg {
    width: 35px !important;
    height: 35px !important;
  }

  .header-controls {
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .icon-group {
    gap: 0.125rem;
  }

  .btn-icon {
    padding: 0.5rem;
  }

  .btn-icon svg {
    width: 24px !important;
    height: 24px !important;
  }

  .icon-separator {
    height: 1.25rem;
    margin: 0 0.25rem;
  }

  .search-input-group {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .tags-grid {
    gap: 0.375rem;
  }

  .tag {
    font-size: 0.6875rem;
    padding: 0.1875rem 0.625rem;
  }

  .site-logo {
    height: 2rem;
  }
}

@media (max-width: 480px) {
  .header-container {
    padding: 0 0.75rem;
  }

  .header-content {
    padding: 0.5rem 0;
    gap: 0.75rem;
  }

  .site-title {
    font-size: 1rem;
    order: 1;
    width: 100%;
  }

  .site-title a span:first-child {
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
  }

  .site-title a span:last-child {
    font-size: 0.95rem !important;
  }

  /* Lightbulb icon smaller mobile sizing */
  .site-title svg {
    width: 28px !important;
    height: 28px !important;
  }

  .header-controls {
    order: 2;
    width: 100%;
    justify-content: center;
    gap: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border-primary);
  }

  .btn-icon {
    padding: 0.375rem;
  }

  .btn-icon svg {
    width: 20px !important;
    height: 20px !important;
  }

  .icon-separator {
    height: 1rem;
    margin: 0 0.375rem;
  }

  .search-input-group {
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-input-group .btn {
    width: 100%;
  }

  .filter-panel {
    margin: 0 -0.75rem;
    border-radius: 0;
  }

  .tags-grid {
    gap: 0.25rem;
    margin: 0 0.5rem;
  }

  .tag {
    font-size: 0.625rem;
    padding: 0.125rem 0.5rem;
  }

  .active-filters {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
  }

  .active-filters > span {
    font-weight: 600;
  }
}

@media (max-width: 360px) {
  .header-container {
    padding: 0 0.5rem;
  }

  .site-title a span:last-child {
    font-size: 0.85rem !important;
  }

  /* Lightbulb icon extra small mobile sizing */
  .site-title svg {
    width: 24px !important;
    height: 24px !important;
  }

  .header-controls {
    gap: 0.25rem;
  }

  .icon-group {
    gap: 0.1rem;
  }

  .btn-icon {
    padding: 0.25rem;
    /* Increase touch target for very small screens */
    min-width: 32px;
    min-height: 32px;
  }

  .btn-icon svg {
    width: 18px !important;
    height: 18px !important;
  }

  .icon-separator {
    margin: 0 0.25rem;
  }

  /* Ensure site title doesn't break on very small screens */
  .site-title a {
    max-width: 100%;
    overflow: hidden;
  }

  .site-title a span:last-child {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* Language Switcher - single flag button that opens an EN/SK dropdown */
.lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Flag chip (shared by trigger + menu items) - fixed box so both flags render
   the exact same size regardless of their native aspect ratio. */
.lang-switcher .lang-flag-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-secondary);
  box-sizing: border-box;
  flex-shrink: 0;
}

.lang-switcher .lang-flag {
  width: 100%;
  height: 100%;
  display: block;
}

/* Trigger: own class (NOT .btn-icon) so the global .btn-icon svg rule can't
   resize the flag/caret. Matches the icon buttons' look. */
.lang-switcher .lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0.375rem;
  color: var(--text-secondary);
  transition: background-color 0.2s, color 0.2s;
}

.lang-switcher .lang-trigger:hover {
  background-color: var(--background-secondary);
  color: var(--text-primary);
}

.lang-switcher .lang-caret {
  width: 11px;
  height: 7px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.lang-switcher .lang-trigger[aria-expanded="true"] .lang-caret {
  transform: rotate(180deg);
}

/* Dropdown menu */
.lang-switcher .lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 172px;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-sm);
  z-index: 1000;
}

.lang-switcher .lang-menu[hidden] {
  display: none;
}

.lang-switcher .lang-menu-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color 0.15s;
}

.lang-switcher .lang-menu-item:hover {
  background-color: var(--background-secondary);
}

/* Selected language: rounded-rectangle highlight around the flag + text
   (instead of a checkmark). */
.lang-switcher .lang-menu-item.active {
  background-color: var(--accent-light);
  color: var(--accent-primary);
}

.lang-switcher .lang-menu-label {
  flex: 1 1 auto;
}

/* v2 taxonomy: "pick one" hint on single-select filter dimensions */
.tag-group-mode {
    font-weight: 400;
    font-size: 0.75rem;
    opacity: 0.65;
    margin-left: 0.3rem;
}

/* Single enabled language: flag shown, but the selector is visibly disabled */
.lang-switcher.single .lang-trigger-disabled {
  cursor: default;
  opacity: 0.5;
  pointer-events: none;
}
.lang-switcher.single .lang-trigger-disabled:hover { background: transparent; box-shadow: none; }

/* Configurable emoji flag (fills the 30x20 flag box like the inline SVG flags) */
.lang-flag-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 1.15rem;
  line-height: 1;
}

/* Mobile: on small screens the header controls wrap to a centered, full-width row
   and the language switcher is the LEFTMOST control. The default right-aligned menu
   (right: 0) would then extend off the LEFT edge of the screen, where the header's
   overflow clips it - so the dropdown "does not expand into the visible area".
   Anchor it to the left instead so it opens into view, and cap its width to the
   viewport. */
@media (max-width: 480px) {
  .lang-switcher .lang-menu {
    right: auto;
    left: 0;
    max-width: calc(100vw - 1.5rem);
  }
}
