/* Оверлей поиска по доке (static/js/mg-search.js). Кнопка-лупа .mg-search-btn в шапке.
   Цвета как у остального сайта: светлая и тёмная тема (data-theme на <html>). */

/* Кнопка-лупа в шапке: размер как у переключателя темы, иконка как на mailganer.com. */
.mg-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--mgh-text, #000);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, color 0.2s;
}
/* Без подложки-кружка: как на mailganer.com, у поиска меняется только цвет значка.
   Серый в покое — бледный #e1e1e1 (точный цвет значка на mailganer.com), синий #0062ad при наведении. */
.mg-search-btn { color: #c2c2c2; } /* как лупа на mailganer.com (search.png) */
.mg-search-btn:hover, .mg-search-btn:focus-visible { color: #0077bb; } /* search_hover.png */
/* Отступ от пунктов меню слева, как между пунктами на mailganer.com. */
.mg-search-btn { margin-left: 12px; }
/* Значок — svg в стиле mailganer.com (толстое кольцо-линза + чёткая ручка влево-вниз), пропорции
   сняты с search.webp. Цвет через currentColor, поэтому перекрашивается под тему и наведение. */
.mg-search-btn svg { display: block; width: 20px; height: 21px; }
/* Линза в верхней трети значка, поэтому при геометрическом центрировании он смотрится выше букв меню.
   Опускаем на 3px: центр линзы встаёт на середину заглавных. */
@media (min-width: 997px) { .mg-search-btn svg { transform: translateY(3px); } }
[data-theme='dark'] .mg-search-btn { color: #a8b3c1; }
[data-theme='dark'] .mg-search-btn:hover, [data-theme='dark'] .mg-search-btn:focus-visible { color: #4c9fe6; }

.mg-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 72px 16px 16px;
  background: rgba(17, 23, 31, 0.45);
  font-family: 'RF Dewi', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
.mg-search-overlay[hidden] { display: none; }
html.mg-search-open { overflow: hidden; }

.mg-search-modal {
  width: min(640px, 100%);
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e6eaf0;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.mg-search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #e6eaf0;
}
.mg-search-field svg { flex: none; width: 20px; height: 20px; color: #5f6b7a; }
.mg-search-field input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  font: 600 18px/1.2 inherit;
  color: #1c1e21;
}
.mg-search-field input::placeholder { color: #9aa5b1; font-weight: 500; }
.mg-search-field kbd {
  flex: none;
  padding: 2px 7px;
  font: 600 12px/1 inherit;
  color: #5f6b7a;
  background: #f1f3f5;
  border: 1px solid #e0e4e9;
  border-radius: 6px;
}

.mg-search-results {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}
.mg-search-results[hidden] { display: none; }

.mg-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.mg-search-item.is-active { background: #eef4fb; }
.mg-search-method {
  flex: none;
  min-width: 52px;
  padding: 3px 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #0062ad;
  background: #e8f1fa;
  border-radius: 6px;
}
.mg-search-text { min-width: 0; display: flex; flex-direction: column; }
.mg-search-title { color: #1c1e21; font-size: 15px; font-weight: 600; }
.mg-search-sub {
  color: #5f6b7a;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mg-search-empty { padding: 18px 12px; color: #5f6b7a; font-weight: 500; text-align: center; }

[data-theme='dark'] .mg-search-modal { background: #151a21; border-color: #232a34; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6); }
[data-theme='dark'] .mg-search-field { border-bottom-color: #232a34; }
[data-theme='dark'] .mg-search-field input { color: #e3e3e3; }
[data-theme='dark'] .mg-search-field input::placeholder { color: #6e7a8a; }
[data-theme='dark'] .mg-search-field kbd { color: #a8b3c1; background: #0e1116; border-color: #3a4554; }
[data-theme='dark'] .mg-search-item.is-active { background: #1f2a38; }
[data-theme='dark'] .mg-search-method { color: #74b6ec; background: #16222f; }
[data-theme='dark'] .mg-search-title { color: #e3e3e3; }
[data-theme='dark'] .mg-search-sub, [data-theme='dark'] .mg-search-empty { color: #a8b3c1; }

@media (max-width: 600px) {
  .mg-search-overlay { padding: 56px 10px 10px; }
  .mg-search-field input { font-size: 16px; }
  .mg-search-field kbd { display: none; }
}
