/* ============================================================
   HEADER — DistrOSList
   Cubre header, mega-menú,
   buscador (PC y móvil), overlay de búsqueda móvil y hamburguesa.
   Las variables :root siguen viviendo en cada página.
   ============================================================ */
/* El wrapper del header no debe crear un bloque que rompa el sticky */
#site-header {
  display: block;
  position: sticky;
  top: 0;
  z-index: 1000;
}
/* ============================================================
   HEADER PRINCIPAL
   ============================================================ */
header {
  width: 100%;
  background: rgba(20, 20, 20, 0.1);
  color: white;
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--border);
  min-height: 50px;
  isolation: isolate;
}

header::before {
  content: '';
  position: absolute;
  inset: 0;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: -1;
  pointer-events: none;
}
.nav-container { max-width: 1370px; margin: 0 auto; padding: 0 20px; position: relative; }
header nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 50px;
  min-height: 50px;
  gap: 12px;
  position: relative;
}
.logo { display: flex; align-items: center; flex-shrink: 0; text-decoration: none !important; border-bottom: none !important; }
.logo:hover img { filter: drop-shadow(0 0 1px rgba(251, 251, 251, 0.4)) drop-shadow(0 0 1px rgba(251, 149, 161, 0.4)); }
.logo .version {
  color: var(--text, #e5e5e5);
  font-size: 0.75rem;
  font-weight: 400;
  margin-left: 4px;
  transition: color 0.3s ease;
  text-decoration: none;
}
.logo .version:hover {
  color: var(--red, #ff0000);
}
.logo img { height: 30px; width: auto; display: block; }

.menu-items { display: flex; align-items: center; gap: 0; flex: 1; justify-content: flex-end; }

/* ============================================================
   MENÚ ITEMS
   ============================================================ */
.menu-item {
  text-decoration: none;
  color: #e5e5e5;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 50px;
  cursor: pointer;
  font-weight: 300;
  font-size: 0.88rem;
  transition: color 0.1s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  border: none;
  background: transparent;
}
.menu-item:hover,
.menu-item:focus,
.menu-item:focus-visible {
  color: #ffffff;
  background: rgb(17, 17, 17);
  transition: color 1s ease;
  text-decoration: none;
}
.menu-item:visited, .menu-item:active, .menu-item:link { color: #e5e5e5; }
.menu-item:hover:visited, .menu-item:focus:visited { color: #ffffff; }

.menu-item::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 1px;
  background: var(--red);
  transition: width 0.3s ease;
}
.menu-item:hover::before, .menu-item:focus-visible::before { width: 60%; }

/* Marca la pestaña activa según data-page del body */
.menu-item.active-page { color: #ffffff; }
.menu-item.active-page::before { width: 60%; }

/* ===== BOTÓN BUSCAR (PC) ===== */
.header-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 14px;
  min-width: 150px;
  max-width: 240px;
  margin: 0 8px 0 4px;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.header-search:hover {
  border-color: var(--darkred);
  background: #000000;
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.08);
}
.header-search:hover .header-search-label { color: var(--text); }
.header-search:hover .header-search-kbd { background: var(--text); border-color: var(--text-dim); color: var(--darkred); }
.header-search:active { transform: scale(0.98); box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.15); }
.header-search:focus-visible { outline: 2px solid var(--darkred); outline-offset: 2px; }
.header-search-icon { font-size: 1rem; flex-shrink: 0; line-height: 1; color: var(--text-dim); }
.header-search-label { flex: 1; text-align: left; color: var(--text-dim); }
.header-search-kbd {
  font-family: 'Ubuntu Mono', monospace;
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #1e1e1e;
  border: 1px solid var(--border);
  color: var(--text);
  line-height: 1;
  flex-shrink: 0;
}
.header-search-mobile {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.header-search-mobile:active { background: rgba(255,255,255,0.06); }

/* ===== HAMBURGUESA ===== */
.hamburger {
  display: none;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: #e5e5e5;
  transition: all 0.3s ease;
  user-select: none;
  z-index: 1001;
  position: relative;
  flex-shrink: 0;
  padding: 0;
  font-family: 'Segoe UI', 'Arial Unicode MS', sans-serif;
  line-height: 1;
}
.hamburger:hover { color: #ffffff; opacity: 0.8; }

/* ===== MEGA MENÚS ===== */
.mega-menu {
  display: block;
  position: absolute;
  top: 50px;
  left: 0;
  width: 100%;
  background: #1c1c1c80;
  backdrop-filter: blur(8px);
  border-top: 1px solid #333;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: scaleY(0);
  transform-origin: top center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 0.2);
}
.mega-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scaleY(1);
  pointer-events: auto;
  max-height: 800px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.mega-container {
  max-width: 1370px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 40px;
  padding: 0px 20px 40px;
}
.tab {
  padding: 15px;
  cursor: pointer;
  margin-bottom: 0px;
  transition: all 0.3s;
  background: rgba(20, 20, 20, 0.88);
  backdrop-filter: blur(20px);
  font-weight: 500;
  font-size: 1.0rem;
  border-bottom: 1px solid #333;
  border-bottom-right-radius: 0px;
  border-top-right-radius: 0px;
}
.tab:hover { background: rgba(10,10,10, 0.88); color: #c67373; transition: color 1s ease; }
.tab.active { background: rgba(10, 10, 10, 0.88); backdrop-filter: blur(20px); color: #d60b23; }

.right-content {
  background: rgba(10, 10, 10, 0.88);
  backdrop-filter: blur(20px);
  display: none;
  grid-template-columns: repeat(2, 2fr);
  padding: 8px;
  border: 1px solid #333;
  border-bottom-right-radius: 16px;
  margin-left: -40px;
}
.right-content.active { display: grid; }
.column h4 { padding: 0 0 10px 0; color: #ca0f24; margin-top: 20px; margin-bottom: 10px; margin-left: 20px; font-size: 1.0rem; font-weight: 500; }
.column ul { list-style: none; }
.column ul li { margin-bottom: 10px; margin-left: 20px; border-bottom: 1px solid var(--border); padding: 10px; font-size: 1.0rem; font-weight: 500; }
.column ul li:hover { background: #1c1c1c; padding: 10px; border-top-right-radius: 8px; border-top-left-radius: 8px; margin-left: 20px; }
.column ul li small { margin: 0 auto; color: #fff; font-size: 1rem; }
.column ul a { color: #ccc; text-decoration: none; padding: 8px; margin: 8px; }
.column ul a:hover { color: #c67373; }

/* ===== MENÚ MÓVIL (overlay hamburguesa) ===== */
.mobile-menu-overlay {
  display: none;
  position: fixed;
  top: 50px;
  left: 0px;
  width: 100%;
  height: calc(100vh - 60px);
  background: #141414;
  z-index: 999;
  overflow-y: auto;
  padding-bottom: 40px;
}
.mobile-menu-overlay.active { display: block; }
.mobile-panel { display: none; }
.mobile-panel.active { display: block; }
.mobile-list { list-style: none; padding: 0; margin: 0; }
.mobile-item {
  padding: 18px 20px;
  border-bottom: 1px solid #333;
  color: #fff;
  font-weight: 400;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mobile-item:hover, .mobile-item:active { background: #2c2c2c; }
.mobile-item::after { content: "❯"; font-size: 1.05rem; color: #ca0f24; font-weight: 500; }
.mobile-back-btn {
  background: #111111;
  padding: 15px 20px;
  color: #ca0f24;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  border-bottom: 1px solid #444;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mobile-back-btn::before { content: "❮"; font-size: 1.1rem; }
.mobile-content-wrapper { padding: 10px 20px; }
.mobile-section-title { color: #ca0f24; font-size: 1.1rem; font-weight: 500; margin: 15px 0 10px 0; padding-bottom: 5px; border-bottom: 1px solid #333; }
.mobile-links-list { list-style: none; }
.mobile-links-list li { padding: 0px 0px; border-bottom: 1px solid #2a2a2a; }
.mobile-links-list a { color: #c9c9c9; text-decoration: none; font-weight: 500; font-size: 1.1rem; display: block; }

body.forced-mobile .menu-items { display: none !important; }
body.forced-mobile .hamburger { display: block !important; }
body.forced-mobile .mega-menu { display: none !important; }

/* ============================================================
   OVERLAY DE BÚSQUEDA MÓVIL
   ============================================================ */
@media (max-width: 1179px) {
  .mobile-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: #0f0f0f;
    display: flex;
    flex-direction: column;
    padding: 0;
    animation: slideDown 0.2s ease-out;
  }
  .mobile-search-overlay[hidden] { display: none !important; }
  .mobile-search-hint .hint-esc { display: none; }
  @keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes slideUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-8px); } }
  .mobile-search-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 20px;
    background: #141414;
    border-bottom: none;
    gap: 10px;
  }
  .mobile-search-icon { display: none; }
  .mobile-search-header input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 1.1rem;
    min-width: 0;
    padding: 12px 0 4px;
    margin-top: 8px;
  }
  .mobile-search-header input::placeholder { color: var(--text-dim); }
  .mobile-search-close {
    background: transparent;
    border: none;
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.15s;
    padding: 0;
  }
  .mobile-search-close:hover, .mobile-search-close:active { color: var(--red); background: rgba(255, 255, 255, 0.05); }
  .mobile-search-clear {
    background: var(--darkred);
    color: var(--text);
    border: none;
    padding: 4px;
    border-radius: 18px;
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
    display: inline;
    vertical-align: baseline;
    transition: color 0.15s;
    text-decoration: none;
  }
  .mobile-search-clear:hover, .mobile-search-clear:active { color: var(--text-dim); }
  .mobile-search-hint {
    padding: 8px 16px;
    font-size: 0.72rem;
    color: var(--text-dim);
    background: #0d0d0d;
    border-bottom: 1px solid var(--border);
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .mobile-search-hint kbd {
    font-family: 'Ubuntu Mono', monospace;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #1e1e1e;
    border: 1px solid var(--border);
    color: var(--text);
    line-height: 1;
  }
  .mobile-search-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 24px;
  }
  #mobile-search-results { display: flex; flex-direction: column; gap: 8px; }
}
@media (min-width: 1180px) {
  .mobile-search-overlay { display: none !important; }
}

/* ============================================================
   BUSCADOR GLOBAL (resultados)
   ============================================================ */
#mega-search-results {
  max-height: 450px;
  overflow-y: auto;
  padding: 8px;
  column-count: 3;
  column-gap: 10px;
}
#mega-search-results .search-result-item {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  display: inline-block;
  width: 100%;
  margin-bottom: 10px;
  transition: all 0.2s ease;
}
#mega-search-results .search-result-item:hover {
  background: var(--card-bg-hover) !important;
  border-color: var(--accent) !important;
}
#mega-search-results .result-section-title {
  column-span: all;
  -webkit-column-span: all;
  display: block;
  width: 100%;
  margin: 12px 0 8px 0;
}
@media (max-width: 1100px) { #mega-search-results { column-count: 2; } }
@media (max-width: 700px) { #mega-search-results { column-count: 1; } }

#mobile-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px 0;
}

/* Hints del modal PC */
.search-hints {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
  user-select: none;
}
.search-hints kbd {
  font-family: 'Ubuntu Mono', monospace;
  font-size: 0.77rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #1e1e1e;
  border: 1px solid var(--border);
  color: var(--text);
  line-height: 1;
  min-width: 20px;
  text-align: center;
}
.search-hints-sep { color: #444; font-weight: 700; }
@media (max-width: 1024px) { .search-hints { display: none; } }

/* Contador y estado vacío */
.search-results-count {
  grid-column: 1 / -1;
  column-span: all;
  -webkit-column-span: all;
  display: block;
  width: 100%;
  padding: 6px 10px 10px 10px;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.2px;
}
.search-empty {
  grid-column: 1 / -1;
  column-span: all;
  -webkit-column-span: all;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px 32px;
  color: var(--text-dim);
  width: 100%;
}
.search-empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.6; line-height: 1; }
.search-empty-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.search-empty-msg { font-size: 0.9rem; color: var(--text-dim); margin-bottom: 22px; }
.search-empty-hint { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); margin-bottom: 12px; }
.search-empty-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 560px; margin-bottom: 26px; }
.suggestion-chip {
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.suggestion-chip:hover { background: var(--accent); color: #9f0000; border-color: var(--accent); transform: translateY(-1px); }
.suggestion-chip:active { transform: translateY(0); }
.search-empty-footer { font-size: 0.82rem; color: var(--text-dim); line-height: 1.6; max-width: 380px; }
.search-empty-footer a { color: var(--red); text-decoration: underline; font-weight: 600; }
.search-empty-footer a:hover { color: #ff5555; }

/* Input del modal PC con botón limpiar */
.mega-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 15px;
}
.mega-search-input-wrapper input {
  width: 100%;
  padding: 12px 44px 12px 18px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.mega-search-input-wrapper input:focus { border-color: var(--accent); }
.mega-search-input-wrapper input::placeholder { color: var(--text-dim); }
.mega-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
}
.mega-search-clear:hover { background: rgba(255, 0, 0, 0.1); color: var(--red); }
.mega-search-clear:active { transform: translateY(-50%) scale(0.92); }
.mega-search-clear[hidden] { display: none !important; }

/* ============================================================
   RESPONSIVE HEADER
   ============================================================ */
@media (max-width: 1024px) {
  .menu-items { display: none !important; }
  .hamburger { display: flex !important; width: 36px; height: 36px; }
  .mega-menu { display: none !important; }
  .logo img { height: 26px; }
  header { min-height: 48px; }
  header nav { height: 48px; min-height: 48px; gap: 4px; }
  .mobile-menu-overlay { top: 48px; height: calc(100vh - 48px); }
  .header-search-mobile { display: inline-flex; align-items: center; justify-content: center; }
  .header-search { display: none !important; }
  header nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .logo { flex: 0 0 auto; }
  .hamburger { display: flex !important; width: 36px; height: 36px; }
  .header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    margin-left: auto;
  }
}