/* =====================================================================
   Energie+ — Header search (iOS 26 "liquid glass" look)
   ---------------------------------------------------------------------
   Markup ....... lightweb/headers/header*.html   (#ep_search_zone)
   Behaviour .... assets/js/search.js
   Loaded by .... every header, after extra.css
   ===================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --ep-search-max: 920px;
  --ep-search-h: 46px;
  --ep-font: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --ep-text: var(--bs-gray-900, #071437);
  --ep-text-2: var(--bs-gray-700, #4b5675);
  --ep-text-3: var(--bs-gray-500, #99a1b7);
  --ep-accent: var(--bs-primary, #1b84ff);
  --ep-accent-rgb: var(--bs-primary-rgb, 27, 132, 255);
  --ep-glass: rgba(255, 255, 255, .58);
  --ep-glass-strong: rgba(255, 255, 255, .88);
  --ep-glass-border: rgba(0, 0, 0, .07);
  --ep-glass-highlight: rgba(255, 255, 255, .9);
  --ep-field-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 10px 30px -12px rgba(0, 0, 0, .18);
  --ep-panel-bg: rgba(255, 255, 255, .82);
  --ep-panel-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 28px 70px -18px rgba(0, 0, 0, .35);
  --ep-sep: rgba(0, 0, 0, .08);
  --ep-row-hover: rgba(0, 0, 0, .04);
  --ep-row-active: rgba(var(--ep-accent-rgb), .10);
  --ep-thumb-bg: linear-gradient(145deg, rgba(0, 0, 0, .05), rgba(0, 0, 0, .11));
  --ep-chip-bg: rgba(var(--ep-accent-rgb), .10);
  --ep-chip-bg-hover: rgba(var(--ep-accent-rgb), .20);
  --ep-chip-fg: var(--ep-accent);
  --ep-muted-bg: rgba(0, 0, 0, .06);
  --ep-focus-ring: rgba(var(--ep-accent-rgb), .22);
  --ep-clear-bg: rgba(120, 130, 157, .38);
  --ep-clear-bg-hover: rgba(120, 130, 157, .62);
}

html[data-bs-theme="dark"] {
  --ep-glass: rgba(34, 36, 44, .62);
  --ep-glass-strong: rgba(34, 36, 44, .92);
  --ep-glass-border: rgba(255, 255, 255, .10);
  --ep-glass-highlight: rgba(255, 255, 255, .09);
  --ep-field-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
  --ep-panel-bg: rgba(28, 30, 37, .88);
  --ep-panel-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 28px 70px -18px rgba(0, 0, 0, .8);
  --ep-sep: rgba(255, 255, 255, .09);
  --ep-row-hover: rgba(255, 255, 255, .05);
  --ep-row-active: rgba(var(--ep-accent-rgb), .18);
  --ep-thumb-bg: linear-gradient(145deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .13));
  --ep-chip-bg: rgba(var(--ep-accent-rgb), .18);
  --ep-chip-bg-hover: rgba(var(--ep-accent-rgb), .30);
  --ep-chip-fg: #7fb8ff;
  --ep-muted-bg: rgba(255, 255, 255, .08);
  --ep-clear-bg: rgba(255, 255, 255, .22);
  --ep-clear-bg-hover: rgba(255, 255, 255, .38);
}

/* ---------- Header layout: logo | search (centered, grows) | settings ---------- */
.ep-search-zone {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 20px;
}

.ep-search {
  position: relative;
  width: 100%;
  max-width: var(--ep-search-max);
  margin: 0;
  font-family: var(--ep-font);
}

/* Lift the header above the fixed sidebar while the panel is open */
body.ep-search-open #kt_app_header {
  z-index: 1090;
}

/* ---------- Field ---------- */
.ep-search-input {
  display: block;
  width: 100%;
  height: var(--ep-search-h);
  margin: 0;
  padding: 0 48px;
  border: 1px solid var(--ep-glass-border);
  border-radius: 999px;
  background: var(--ep-glass);
  color: var(--ep-text);
  font: 500 16px/1.2 var(--ep-font);
  letter-spacing: -.01em;
  box-shadow: inset 0 1px 0 var(--ep-glass-highlight), var(--ep-field-shadow);
  -webkit-backdrop-filter: blur(22px) saturate(1.7);
  backdrop-filter: blur(22px) saturate(1.7);
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.ep-search-input::placeholder {
  color: var(--ep-text-3);
  opacity: 1;
}

.ep-search-input::-webkit-search-cancel-button,
.ep-search-input::-webkit-search-decoration,
.ep-search-input::-webkit-search-results-button {
  -webkit-appearance: none;
  display: none;
}

.ep-search-input:hover {
  background: var(--ep-glass-strong);
}

.ep-search-input:focus,
.ep-search-input:focus-visible {
  background: var(--ep-glass-strong);
  border-color: rgba(var(--ep-accent-rgb), .55);
  box-shadow: inset 0 1px 0 var(--ep-glass-highlight), 0 0 0 4px var(--ep-focus-ring), var(--ep-field-shadow);
}

.ep-search-icon {
  position: absolute;
  left: 17px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  color: var(--ep-text-2);
  pointer-events: none;
  display: flex;
}

.ep-search-icon svg {
  width: 100%;
  height: 100%;
}

.ep-search-clear {
  position: absolute;
  right: 13px;
  top: 50%;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  transform: translateY(-50%);
  background: var(--ep-clear-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease, background-color .15s ease;
}

.ep-search-clear svg {
  width: 10px;
  height: 10px;
}

.ep-search-clear:hover {
  background: var(--ep-clear-bg-hover);
}

.ep-search.has-value:not(.is-loading) .ep-search-clear {
  opacity: 1;
  visibility: visible;
}

.ep-search-spinner {
  position: absolute;
  right: 15px;
  top: calc(50% - 9px);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(var(--ep-accent-rgb), .18);
  border-top-color: var(--ep-accent);
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease;
  animation: ep-spin .75s linear infinite;
}

.ep-search.is-loading .ep-search-spinner {
  opacity: 1;
  visibility: visible;
}

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

/* ---------- Panel (floating glass sheet under the field) ---------- */
.ep-search-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  width: min(calc(100% - 40px), var(--ep-search-max));
  z-index: 1200;
  border: 1px solid var(--ep-glass-border);
  border-radius: 24px;
  background: var(--ep-panel-bg);
  color: var(--ep-text);
  font-family: var(--ep-font);
  box-shadow: inset 0 1px 0 var(--ep-glass-highlight), var(--ep-panel-shadow);
  -webkit-backdrop-filter: blur(28px) saturate(1.8);
  backdrop-filter: blur(28px) saturate(1.8);
  overflow: hidden;
  opacity: 0;
  transform: translate(-50%, -6px) scale(.985);
  transform-origin: 50% 0;
  transition: opacity .16s ease, transform .22s cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}

.ep-search-panel[hidden] {
  display: none !important;
}

.ep-search-panel.is-open {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}

.ep-sp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 8px;
}

.ep-sp-title {
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ep-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ep-sp-title q {
  quotes: "\201C" "\201D";
  text-transform: none;
  letter-spacing: 0;
  color: var(--ep-text);
}

.ep-sp-close {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ep-muted-bg);
  color: var(--ep-text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color .15s ease;
}

.ep-sp-close svg {
  width: 11px;
  height: 11px;
}

.ep-sp-close:hover {
  background: var(--ep-clear-bg);
  color: #fff;
}

/* ---------- Results list (inset grouped list) ---------- */
.ep-sp-list {
  list-style: none;
  margin: 0;
  padding: 2px 0 6px;
  max-height: min(62vh, 640px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.ep-sr {
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) minmax(150px, 32%);
  gap: 16px;
  align-items: center;
  padding: 10px 18px;
  cursor: pointer;
  transition: background-color .12s ease;
}

.ep-sr+.ep-sr::before {
  content: "";
  position: absolute;
  left: 90px;
  right: 18px;
  top: 0;
  height: 1px;
  background: var(--ep-sep);
  transition: opacity .12s ease;
}

.ep-sr:hover {
  background: var(--ep-row-hover);
}

.ep-sr.is-active {
  background: var(--ep-row-active);
}

.ep-sr:hover::before,
.ep-sr.is-active::before,
.ep-sr:hover+.ep-sr::before,
.ep-sr.is-active+.ep-sr::before {
  opacity: 0;
}

/* column 1: thumbnail (or a neutral glyph when the article has no image) */
.ep-sr-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 16px;
  overflow: hidden;
  background: var(--ep-thumb-bg);
  color: var(--ep-text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
}

.ep-sr-thumb svg {
  width: 22px;
  height: 22px;
  opacity: .75;
}

.ep-sr-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .28s ease;
}

.ep-sr-thumb img.is-loaded {
  opacity: 1;
}

/* column 2: title */
.ep-sr-main {
  min-width: 0;
}

.ep-sr-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.01em;
  color: var(--ep-text);
  text-decoration: none;
  transition: color .12s ease;
}

.ep-sr-title:hover,
.ep-sr-title:focus {
  color: var(--ep-accent);
  text-decoration: none;
}

/* column 3: keywords */
.ep-sr-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.ep-chip {
  display: inline-block;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--ep-chip-bg);
  color: var(--ep-chip-fg);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  transition: background-color .12s ease;
}

.ep-chip:hover,
.ep-chip:focus {
  background: var(--ep-chip-bg-hover);
  color: var(--ep-chip-fg);
  text-decoration: none;
}

.ep-chip.is-more {
  background: var(--ep-muted-bg);
  color: var(--ep-text-2);
}

/* ---------- Footer, empty, error, skeleton ---------- */
.ep-sp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px 12px;
  border-top: 1px solid var(--ep-sep);
  font-size: 12.5px;
  color: var(--ep-text-2);
}

.ep-sp-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ep-accent);
  font: 600 12.5px/1 var(--ep-font);
  cursor: pointer;
  transition: background-color .12s ease;
}

.ep-sp-more:hover {
  background: var(--ep-chip-bg);
}

.ep-sp-foot kbd {
  display: inline-block;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--ep-muted-bg);
  color: var(--ep-text-2);
  font: 600 11px/1 var(--ep-font);
}

.ep-sp-empty,
.ep-sp-error {
  padding: 34px 18px 38px;
  text-align: center;
  font-size: 14px;
  color: var(--ep-text-2);
}

.ep-sp-empty svg {
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
  opacity: .45;
}

.ep-sp-empty q {
  quotes: "\201C" "\201D";
  color: var(--ep-text);
  font-weight: 600;
}

.ep-sp-error button {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ep-chip-bg);
  color: var(--ep-accent);
  font: 600 13px/1 var(--ep-font);
  cursor: pointer;
}

.ep-sr.is-skeleton {
  pointer-events: none;
}

.ep-sk {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--ep-muted-bg) 25%, var(--ep-row-active) 45%, var(--ep-muted-bg) 65%);
  background-size: 400% 100%;
  animation: ep-shimmer 1.3s ease infinite;
}

.ep-sr.is-skeleton .ep-sr-thumb {
  background: var(--ep-muted-bg);
}

@keyframes ep-shimmer {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: 0 0;
  }
}

/* ---------- Tablet & phone ---------- */
@media (max-width: 991.98px) {
  :root {
    --ep-search-h: 40px;
  }

  /* logo block stops reserving the sidebar width; the search takes the middle */
  .app-header .app-header-logo,
  [data-kt-app-sidebar-enabled="true"] .app-header .app-header-logo {
    width: auto !important;
    margin-right: 4px !important;
    flex: 0 0 auto;
  }

  .app-header .app-header-logo .logo {
    display: inline-block !important;
  }

  .app-header .app-header-logo .logo img {
    max-width: 112px;
  }

  #kt_header_user_menu_toggle {
    margin-left: 6px !important;
  }

  /* the panel anchors to the whole header row instead of the field */
  #kt_app_header_wrapper {
    position: relative;
  }

  .ep-search-zone {
    position: static;
    padding: 0 8px;
  }

  .ep-search-input {
    padding: 0 40px;
    font-size: 16px;
    /* 16px prevents the iOS focus zoom */
  }

  .ep-search-icon {
    left: 13px;
    width: 18px;
    height: 18px;
  }

  .ep-search-clear {
    right: 10px;
  }

  .ep-search-spinner {
    right: 12px;
  }

  .ep-search-panel {
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    width: auto;
    border-radius: 22px;
    transform: translate(0, -6px) scale(.985);
  }

  .ep-search-panel.is-open {
    transform: translate(0, 0) scale(1);
  }

  .ep-sp-list {
    max-height: calc(100vh - var(--bs-app-header-height, 70px) - 120px);
    max-height: calc(100dvh - var(--bs-app-header-height, 70px) - 120px);
  }

  .ep-sr {
    grid-template-columns: 48px minmax(0, 1fr) minmax(120px, 34%);
    gap: 12px;
    padding: 10px 14px;
  }

  .ep-sr+.ep-sr::before {
    left: 74px;
    right: 14px;
  }

  .ep-sr-thumb {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .ep-sr-title {
    font-size: 15px;
  }

  .ep-sp-head,
  .ep-sp-foot {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* phones: keywords wrap under the title (two visual columns) */
@media (max-width: 575.98px) {
  .ep-sr {
    grid-template-columns: 48px minmax(0, 1fr);
    row-gap: 6px;
  }

  .ep-sr-tags {
    grid-column: 2;
    justify-content: flex-start;
  }

  .ep-sp-foot kbd {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {

  .ep-search-panel,
  .ep-search-input,
  .ep-sr,
  .ep-sr-thumb img,
  .ep-chip {
    transition: none;
  }

  .ep-sk,
  .ep-search-spinner {
    animation-duration: 2s;
  }
}

@media print {
  .ep-search-panel {
    display: none !important;
  }
}
