/* header.css — общая шапка и навигация для всех страниц */
@import url('/mobile-nav.css');

/* ========== Страница на всю высоту: контент растягивается, футер внизу ========== */
html {
  height: 100%;
}

body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Текстовые чаты: высота под мобильный viewport (общий site-footer только на главной) */
body[data-text-chat-page] {
  min-height: 100dvh;
  min-height: 100svh;
}

body > main,
body > .nb-layout,
body > .mj-layout,
body > .profile-layout,
body > .gpt-image-layout,
body > .app-layout,
body > .test5-figma-root,
body > .cg-chat-layout,
body > .ds-chat-layout,
body > .suno-layout,
body > .eil-layout,
body > .nodes-layout,
body > .admin-layout,
body > .test-design-layout {
  flex: 1 0 auto;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
}

/*
 * Центрирование карточки; без «width:100% + margin по горизонтали» (переполнение по X на телефонах).
 * Ширину и max-width задаёт .auth-container в auth.css; на мобильных там max-width: none.
 */
body > .auth-container {
  flex: 1 0 auto;
  min-height: 0;
  align-self: center;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.header,
.header .logo,
.header .nav,
.header .nav a,
.header .nav-menu > li > a,
.header .dropdown-toggle,
.header .dropdown-menu,
.header .dropdown-menu .menu-item,
.header .header-right > a,
.header .header-right .logout-btn,
.header .header-right .diamond-balance,
.header .header-right .diamond-balance-link {
  font-family: var(--font, 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 3rem;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}
.logo:hover {
  color: var(--accent);
}
.logo .logo-emoji {
  display: inline-block;
  transition: transform 0.5s;
}
.logo:hover .logo-emoji {
  transform: rotate(360deg);
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  position: relative;
  transition: color 0.2s;
}
.nav a:hover {
  color: var(--accent);
}
.nav-menu {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}
.nav-menu > li {
  position: relative;
}
.nav-menu > li > a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  display: inline-block;
  transition: color 0.2s;
}
.nav-menu > li > a:hover {
  color: var(--accent);
}

.dropdown {
  position: relative;
}
.dropdown::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 20px;
  background: transparent;
  pointer-events: none;
}
.dropdown:hover::after,
.dropdown.is-open::after {
  pointer-events: auto;
}
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  list-style: none;
  padding: 8px 0;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.dropdown-menu::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: 0;
  width: 100%;
  height: 20px;
  background: transparent;
  pointer-events: none;
}
.dropdown:hover .dropdown-menu,
.dropdown.is-open .dropdown-menu,
.dropdown-menu:hover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.dropdown-menu:hover::after {
  pointer-events: auto;
}
.dropdown.open .dropdown-menu {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.dropdown-menu li {
  margin: 0;
}
.dropdown-menu .menu-item {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
}
.dropdown-menu .menu-item:hover {
  background: var(--border-light);
  color: var(--accent);
}
.dropdown-menu .menu-item.active {
  background: rgba(0,102,255,0.06);
  color: var(--accent);
}
.dropdown-menu .menu-item.menu-item--with-icon {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.dropdown-menu .menu-item .menu-item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  object-fit: contain;
}

.btn-login,
.login-link,
.login-link--single,
.btn-signup,
.signup-btn,
.profile-icon,
.header-right,
.header-right .logout-btn,
.header-right .profile-icon,
.header-right .diamond-balance {
  font-family: var(--font, 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif);
}

.btn-login {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  border-radius: 6px;
}
.btn-login:hover {
  color: var(--accent);
  text-decoration: underline;
}

.login-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  border-radius: 6px;
}
.login-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.login-link--single {
  font-weight: 600;
  color: var(--accent);
  padding: 0.5rem 1rem;
}
.login-link--single:hover {
  color: var(--accent-hover);
}

.signup-btn {
  background: var(--accent);
  color: white;
  border: none;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}
.signup-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.profile-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.profile-icon:hover {
  color: var(--accent);
  background: rgba(0, 102, 255, 0.08);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.header-right > a:first-child {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  border-radius: 6px;
  transition: color 0.2s;
}
.header-right > a:first-child:hover {
  color: var(--accent);
}
.header-right .logout-btn {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.2s;
}
.header-right .logout-btn:hover {
  color: var(--accent);
}
.header-right .profile-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  overflow: hidden;
  flex-shrink: 0;
}
.header-right .profile-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.header-right .diamond-balance-link {
  text-decoration: none;
  display: inline-block;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}
.header-right .diamond-balance-link:hover .diamond-balance {
  background: rgba(0, 102, 255, 0.12);
  color: var(--accent, #0066ff);
}
.header-right .diamond-balance {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--border-light);
  display: inline-block;
  transition: background 0.2s, color 0.2s;
}

.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 44px;
  min-height: 44px;
  padding: 10px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.burger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

@media (max-width: 900px) {
  .header .logo-emoji {
    display: none;
  }
  .header {
    position: relative;
    padding: 0.6rem 0.75rem;
  }
  .header-left {
    gap: 0.75rem;
    justify-content: flex-start;
    min-width: 0;
  }
  .header-left .logo {
    position: absolute;
    left: 38%;
    transform: translateX(-50%);
    z-index: 1;
    max-width: min(calc(100vw - 140px), 52vw);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
  }
  .header-left .burger {
    order: -1;
    display: flex;
    flex-shrink: 0;
  }
  .header-right {
    flex-shrink: 0;
    min-width: 0;
    position: relative;
    z-index: 2;
  }
  .login-link--single {
    font-size: 1.05rem;
    padding: 0.6rem 1rem;
  }
  .nav {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 12px;
    right: auto;
    width: min(320px, 82vw);
    background: var(--bg);
    flex-direction: column;
    padding: 4.25rem 1.5rem 1.75rem;
    border-radius: 0 16px 16px 0;
    box-shadow: 0 0 32px rgba(0, 0, 0, 0.28);
    max-height: 100vh;
    overflow-y: auto;
    z-index: 10002;
    transform: translateX(-100%);
    opacity: 0;
    transition: transform 0.25s ease-out, opacity 0.2s ease-out;
  }
  .nav.open {
    display: flex;
    transform: translateX(0);
    opacity: 1;
  }
  .nav.open .nav-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
  }
  .nav.open .nav-menu > li > a,
  .nav.open .dropdown-toggle {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
  }
  .nav.open .dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding-left: 0.75rem;
    margin-top: 0.25rem;
    display: none;
  }
  .nav.open .dropdown.open .dropdown-menu {
    display: block;
  }
  .nav.open .dropdown-menu .menu-item {
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 0.4rem 0.75rem 0.4rem 0.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
  }
  .header-right {
    gap: 0.5rem;
  }
  .header-right .profile-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    font-size: 0.8rem;
  }
}

@media (max-width: 600px) {
  .header {
    padding: 0.75rem 0.75rem;
  }
  .logo {
    font-size: 1.05rem;
  }
  /* Место под бургер слева и баланс+аватар справа — иначе «Нейро Мишка» наезжает на баланс */
  .header-left .logo {
    max-width: min(calc(100vw - 200px), 48vw);
  }
}

/* ========== Общий футер (юр. информация) ========== */
.site-footer {
  margin-top: auto;
  padding: 1.25rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border, #eee);
  background: var(--bg, #fff);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.site-footer-inner {
  max-width: 960px;
  margin: 0 auto;
  text-align: center;
}

.site-footer-legal {
  font-size: 0.8125rem;
  color: var(--text-secondary, #666);
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.875rem;
}

.site-footer-nav a {
  color: var(--accent, #0066ff);
  text-decoration: none;
}

.site-footer-nav a:hover {
  text-decoration: underline;
}

.site-footer-sep {
  color: var(--text-muted, #aaa);
  user-select: none;
}

@media (max-width: 480px) {
  .site-footer-nav {
    flex-direction: column;
    gap: 0.5rem;
  }
  .site-footer-sep {
    display: none;
  }
}
