/* public/assets/layout.css */
/* =========================================================
   Layout — шапка/меню/поиск/мобильное меню/нижняя панель
   + app-shell (sticky layout) + safe bottom-nav
   ========================================================= */

:root{
  --bottom-nav-h: 64px; /* JS перезапишет точнее */
  --app-vh: 100vh;      /* ✅ нативка/клавиатура будут обновлять через capacitor-hacks.js */
}

/* базовые */
html, body { height: 100%; }
body { margin: 0; }

/* ===== App shell: header -> main -> footer ===== */
.app-shell{
  /* ✅ вместо 100vh используем переменную, чтобы не “прыгало” в WebView при клавиатуре/повороте */
  min-height: var(--app-vh, 100vh);
  display: flex;
  flex-direction: column;
}

/* main растягивается */
.app-main{
  flex: 1 1 auto;
  overflow-x: hidden;
}

/* Важно: чтобы футер не прятался под fixed bottom-nav */
.has-bottom-nav .app-shell{
  padding-bottom: var(--bottom-nav-h, 64px);
}

/* ===== Header ===== */
.site-header {
  background: #fff;
  border-bottom: 1px solid #ddd;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 50;
}

/* центрируем внутренности как container */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;

  width: 100%;
  max-width: var(--container, 1280px);
  margin: 0 auto;

  padding: 10px calc(var(--gutter, 16px) + var(--safe-area-inset-x, 0px));
  position: relative;
  gap: 12px;
}

/* Логотип и погода */
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  min-width: 0;
}
.logo-img {
  height: 50px;
  flex-shrink: 0;
}

.weather-inline {
  font-size: 14px;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 0;
}
.weather-inline .desc{ display:none; }

/* правая часть */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Кнопка-иконка (поиск на мобиле) */
.header-icon-btn{
  display: none; /* покажем на мобиле/планшете */
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,.12);
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

/* бургер */
.burger {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(15,23,42,.12);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0;
}

/* кнопка чата (десктоп) */
.desktop-chat { display: inline-flex; }

.open-chat-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 10px;
  transition: background 0.2s;
  position: relative;
}
.open-chat-btn:hover { background: rgba(0,0,0,0.08); }

/* бейдж */
.chat-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #ff3b30;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px #fff;
  pointer-events: none;
  z-index: 10;
}

/* меню пользователя */
.user-dropdown { position: relative; }
.user-name {
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-menu {
  display: none;
  position: absolute;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
  min-width: 220px;
  max-width: min(360px, calc(100vw - 24px));
  overflow: hidden;
  z-index: 3000;
  animation: fadeInMenu 0.15s ease-out;
  border: 1px solid rgba(15,23,42,.08);
}
.header-right .user-menu {
  top: 100%;
  right: 0;
  transform-origin: top right;
}
.user-menu.open { display: block; }

.user-menu a {
  display: block;
  padding: 10px 14px;
  color: #222;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease;
  white-space: nowrap;
}
.user-menu a:hover { background: #f3f4f6; }
.user-menu a:last-child {
  border-top: 1px solid #eee;
  color: #e53935;
}

@keyframes fadeInMenu {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Меню пользователя: вынесенные элементы */
.menu-caption {
  padding: 8px 12px;
  color: rgba(15,23,42,.55);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.menu-sep {
  height: 1px;
  background: rgba(15,23,42,.10);
  margin: 6px 0;
}
.menu-form {
  display: block;
  margin: 0;
}
.menu-danger-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 10px 12px;
  color: #dc2626;
  font-weight: 900;
}

/* десктоп меню */
.main-menu {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 1.2vw, 22px);
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
  row-gap: 8px;
}
.main-menu a {
  text-decoration: none;
  color: #222;
  font-weight: 500;
  transition: 0.2s;
  padding-bottom: 3px;
  white-space: nowrap;
}
.main-menu a:hover { color: var(--theme-color,#0088cc); }
.main-menu a.active {
  color: var(--theme-color,#0088cc);
  border-bottom: 2px solid var(--theme-color,#0088cc);
}

/* Dropdown */
.nav-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.nav-dropdown-toggle {
  background: none;
  border: none;
  margin: 0;
  font: inherit;
  color: #222;
  cursor: pointer;
  font-weight: 500;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 0 3px;
  white-space: nowrap;
}
.nav-dropdown-toggle:hover { color: var(--theme-color,#0088cc); }
.nav-dropdown-toggle.active {
  color: var(--theme-color,#0088cc);
  border-bottom: 2px solid var(--theme-color,#0088cc);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 220px;
  max-width: min(360px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.14);
  overflow: hidden;
  z-index: 4000;
}
.nav-dropdown-menu.open { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 10px 12px;
  color: #111827;
  text-decoration: none;
  font-size: 14px;
}
.nav-dropdown-menu a:hover { background: #f3f4f6; }

/* ✅ для длинных списков (категории организаций) */
.nav-dropdown-menu-scroll{
  max-height: 70vh;
  overflow-y: auto;
}
.nav-dropdown-sep{
  height: 1px;
  background: #eef0f3;
  margin: 6px 0;
}

/* ===== Search ===== */
.search-bar {
  padding: 10px calc(var(--gutter, 16px) + var(--safe-area-inset-x, 0px));
  background: #fafafa;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: center;
}

.search-form {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1fr 220px 120px;
  gap: 10px;
  align-items: center;
}
.search-input,
.search-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 15px;
}
.search-input:focus,
.search-select:focus {
  border-color: var(--theme-color,#0088cc);
}

.search-btn {
  border: none;
  background: linear-gradient(180deg, var(--theme-color,#0088cc), #006fa8);
  color: white;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 18px rgba(0, 136, 204, 0.22);
  transition: transform .08s ease, filter .15s ease, box-shadow .15s ease;
}
.search-btn:hover {
  filter: brightness(1.03);
  box-shadow: 0 10px 22px rgba(0, 136, 204, 0.26);
}
.search-btn:active { transform: translateY(1px); }

/* ===== Mobile menu (drawer) ===== */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  right: 0;

  width: min(86vw, 360px);
  height: 100%;

  background: #fff;
  box-shadow: -4px 0 15px rgba(0,0,0,0.2);

  padding-top: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  padding-left: calc(18px + env(safe-area-inset-left));
  padding-right: calc(18px + env(safe-area-inset-right));

  z-index: 200;
  transform: translateX(100%);
  transition: transform .3s ease;
  overflow-y: auto;
}
.mobile-menu.active {
  display: block;
  transform: translateX(0);
}
.mobile-menu a {
  display: block;
  padding: 10px 0;
  text-decoration: none;
  color: #333;
  border-bottom: 1px solid #eee;
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 150;
}
.mobile-overlay.active { display: block; }

/* mobile dropdown */
.mobile-submenu {
  display: none;
  margin: 6px 0 10px;
  padding-left: 12px;
}
.mobile-submenu a {
  border-bottom: none;
  padding: 8px 0;
  color: #111827;
}
.mobile-submenu.open { display: block; }

.mobile-menu .mobile-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  text-decoration: none;
  color: #333;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  user-select: none;
}
.mobile-menu .mobile-dropdown-toggle span:last-child { opacity: 0.7; }

/* ✅ гостевые ссылки в моб.меню (Войти/Регистрация) */
.mobile-auth-links{
  margin-top: 12px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}
.mobile-auth-links a{
  display: block;
  padding: 10px 0;
  text-decoration: none;
  color: #333;
  border-bottom: 1px solid #eee;
}
.mobile-auth-links a:last-child{
  border-bottom: none;
}

/* ===== Bottom nav (mobile) ===== */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(60px + var(--safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #ddd;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.10);
  z-index: 1000;
  padding-bottom: var(--safe-area-inset-bottom);
}

.bottom-nav a,
.bottom-nav .user-dropdown {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #555;
  font-size: 24px;
  height: 60px;
  cursor: pointer;
}

.bottom-nav a.active,
.bottom-nav .user-dropdown.active {
  color: var(--theme-color,#0088cc);
}

/* FIX: badge должен позиционироваться относительно иконки/ссылки */
.bottom-nav a{ position: relative; }
.bottom-nav .chat-badge{
  top: 8px;
  right: 14px;
}

.bottom-nav .user-dropdown { position: relative; }

.user-menu-toggle{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  height:100%;
  text-decoration:none;
  font-size:26px;
  color:#555;
}

.bottom-nav .user-menu {
  display:none;
  position:absolute;
  bottom:100%;
  right:4px;
  background:#fff;
  border-radius:12px 12px 0 0;
  min-width:190px;
  max-width: min(360px, calc(100vw - 16px));
  box-shadow:0 -3px 14px rgba(0,0,0,.15);
  overflow:hidden;
  animation:fadeUp .15s ease-out;
  z-index:1001;
  border: 1px solid rgba(15,23,42,.08);
}
.bottom-nav .user-menu.open { display:block; }

.bottom-nav .user-menu a {
  display:block;
  padding:12px 16px;
  font-size:15px;
  font-weight:500;
  color:#111;
  text-decoration:none;
  border-bottom:1px solid #f3f4f6;
}
.bottom-nav .user-menu a:hover { background:#f3f4f6; }
.bottom-nav .user-menu a:last-child {
  border-top:1px solid #e5e7eb;
  color:#e11d48;
}

@keyframes fadeUp {
  from { opacity:0; transform:translateY(6px); }
  to   { opacity:1; transform:none; }
}

/* ✅ безопасный caret/focus фикс */
input, textarea, select { caret-color: auto; }

/* ===== Footer ===== */
.app-footer{
  margin-top: 12px;
  padding: 14px 0;
  color: #6b7280;
  font-size: 0.9rem;
}

/* ===== Responsive header ===== */
/* ✅ мобилка+планшеты: до 1024 */
@media (max-width: 1024px) {
  .main-menu { display: none; }
  .burger { display: inline-flex; align-items:center; justify-content:center; }
  .header-right .user-dropdown { display:none; }
  .desktop-chat { display:none; }
  .bottom-nav { display:flex; }

  /* ✅ на мобилке/планшете убираем "Войти/Регистрация" из шапки */
  .auth-links { display: none; }

  /* кнопка поиска видна на мобиле/планшете */
  .header-icon-btn{ display: inline-flex; }

  /* делаем шапку компактнее */
  .logo-img { height: 44px; }
}

/* ===== Mobile: search collapse (app-like) ===== */
@media (max-width: 1024px) {
  .search-bar { display: none; }
  .search-bar.is-open { display: flex; }

  .search-form{
    grid-template-columns: 1fr 44px;
    grid-template-areas:
      "q btn"
      "section section";
    gap: 8px;
    align-items: center;
  }

  .search-input{ grid-area: q; height: 44px; }
  .search-select{ grid-area: section; height: 42px; }

  .search-btn{
    grid-area: btn;
    height: 44px;
    width: 44px;
    padding: 0;
    border-radius: 14px;
  }

  .search-btn span:last-child{ display:none; }
}

@media (max-width: 480px){
  .logo-img{
    height: 40px;
  }

  .bottom-nav a,
  .bottom-nav .user-dropdown{
    font-size: 22px;
  }
}

/* Force LIGHT everywhere (fix iOS Safari dark web-content) */
:root{ color-scheme: light; }
html{ background: var(--bg, #fff); }
body{
  background: var(--bg, #fff);
  color: var(--text, #0f172a);
}

/* На всякий: если где-то есть dark media-ветки — перебиваем */
@media (prefers-color-scheme: dark){
  :root{ color-scheme: light; }
  html{ background: var(--bg, #fff) !important; }
  body{ background: var(--bg, #fff) !important; color: var(--text, #0f172a) !important; }
}

