/* =========================================================================
   header.css — top navigation bar, search input/autocomplete, admin menu.
   Used on every page (loaded by layout.js).
   ========================================================================= */

.main-header {
  background: var(--header-bg);
  padding: 0.35rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  left: 0;
  right: 0;
  font-family: inherit;
  border-bottom: 1px solid var(--header-border);
}

.main-header-inner {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.main-header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex: 0 0 auto;
  min-width: 0;
  justify-self: start;
}

.main-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  flex: 0 0 auto;
  justify-self: end;
}

.main-header * {
  font-family: inherit;
}

.main-header .logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--header-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-self: center;
}

.main-header .logo img {
  height: 65px;
  width: auto;
  max-width: 280px;
  display: block;
}

.main-header nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.main-header nav a,
.main-header nav button {
  color: var(--header-text-soft);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
}

.main-header nav a:hover,
.main-header nav button:hover {
  color: #fff;
  background: #1f1f1f;
}

/* ---------------------------------------------------------------------------
   Search box (top-right of the header)
   --------------------------------------------------------------------------- */
.header-search {
  position: relative;
  width: 380px;
  max-width: 100%;
}

.header-search input {
  width: 100%;
  padding: 0.55rem 0.85rem;
  height: 38px;
  border-radius: var(--radius-pill);
  border: 1px solid #2a2a2a;
  background: #111;
  font-size: 0.95rem;
  color: var(--header-text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.header-search input:focus {
  background: #0c0c0c;
  border-color: #444;
  box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.2);
}

.header-search.is-loading input {
  background: #151515;
}

.header-search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  left: 0;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid #e3e7ef;
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
  display: none;
  z-index: 200;
  max-height: 70vh;
  overflow-y: auto;
}

.header-search-results.active {
  display: block;
}

.header-search-item,
.header-search-item:hover,
.header-search-item:focus,
.header-search-item:active,
.header-search-item:visited {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  text-decoration: none;
  color: #1f2a37;
  border-radius: var(--radius-md);
  transition: background-color 0.2s ease;
}

.header-search-item:hover,
.header-search-item.is-active {
  background-color: var(--color-soft-translucent);
  text-decoration: none;
}

.header-search-thumb {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: #e9edf5;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.header-search-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.header-search-name {
  font-weight: 400;
  font-size: 0.95rem;
}

.header-search-name b {
  font-weight: 700;
  color: #000;
}

.header-search-type {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.header-search-empty {
  padding: 0.65rem 0.75rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------------------
   Admin dropdown (visible only when Origin=Gondor in localStorage)
   --------------------------------------------------------------------------- */
.admin-menu {
  position: relative;
  display: none;
}

.admin-menu-toggle {
  color: var(--color-primary-strong);
  font-weight: 600;
  padding: 0.5rem 1rem !important;
}

.admin-menu-toggle::after {
  content: ' ⌄';
}

.admin-menu-dropdown {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 0.5rem);
  background: var(--surface);
  border: 1px solid #ddd;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 180px;
  z-index: 9999;
}

.admin-menu-dropdown.active {
  display: block;
}

.admin-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1.25rem;
  border: none;
  background: none;
  color: #333;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--line-soft);
}

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

.admin-menu-dropdown button:hover {
  background: #f5f7fa;
  color: var(--color-primary-strong);
}

.admin-menu-dropdown button.exit-btn {
  color: #d32f2f;
  font-weight: 600;
}

.admin-menu-dropdown button.exit-btn:hover {
  background: #ffebee;
}

/* ---------------------------------------------------------------------------
   Responsive header
   --------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .main-header-inner {
    padding: 0 12px;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.75rem;
  }

  .main-header-left {
    width: 100%;
    justify-content: center;
  }

  .main-header nav {
    display: none;
  }

  .main-header-right {
    width: 100%;
  }

  .header-search {
    width: 100%;
  }
}
