/* src/frontend/static/css/header.css */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  flex-wrap: wrap;
  border-radius: 12px;
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* nav links (Изображения / Видео) */
.top-nav {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-weight: 600;
}

.top-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 30px;
  border-radius: 12px;
  font-weight: 400;
}

.top-nav a.active {
  background: var(--bg-active);
  color: var(--text);
  border: 1px solid var(--border-active);
  border-radius: 50px;
}

/* login button */
.btn-login {
  background: var(--accent);
  color: #111111;
  border: 1px solid rgba(214, 255, 63, 0.18);
  padding: 10px 20px;
  border-radius: 50px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.btn-login:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

/* .brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 700;
  font-size: 20px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: inline-block;
}

.brand-title {
  color: var(--text);
  line-height: 1;
  font-weight: 700;
  font-size: 20px;
}

.search-icon {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  display: inline-block;
  flex: 0 0 auto;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.15);
  transition: transform .12s ease, box-shadow .12s ease;
}

#authArea {
  display: flex;
  align-items: center;
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.theme-toggle-btn {
  width: 76px;
  height: 36px;
  border-radius: 36px;
  background: #383838;
  border: 1px solid #464646;
  padding: 0;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.theme-toggle-btn:hover {
  background: #464646;
}

/* Theme Slider Track */
.theme-slider-track {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  box-sizing: border-box;
}

/* Icons on the track */
.theme-slider-track .track-icon {
  color: #888888;
  z-index: 1;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* The Sliding Thumb */
.theme-slider-thumb {
  position: absolute;
  top: 50%;
  left: 5px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #D6FF3F;
  /* Accent green for dark mode */
  display: flex;
  justify-content: center;
  align-items: center;
  transition: left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), background 0.3s ease;
  z-index: 2;
}

.theme-slider-thumb .thumb-icon {
  width: 16px;
  height: 16px;
  color: #111;
  fill: #111;
}

/* Base logic for thumb icons: default is dark mode */
.theme-slider-thumb .theme-icon-sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
  position: absolute;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-slider-thumb .theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
  position: absolute;
  transition: opacity 0.3s ease, transform 0.3s ease;
}


/* LEFT RAIL WRAP - фон + кнопки снизу */
.left-rail-wrap {
  display: none;
  /* hidden by default, shown for authorized users in JS */
  position: fixed;
  left: 25px;
  bottom: 24px;
  /* top: 150px; */
  z-index: 17000;
  align-items: flex-end;
  pointer-events: auto;
}

.left-rail-bg {
  background: var(--panel);
  /* Начальная форма - небольшая пилюля (pill) */
  border-radius: 22px;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  /* Свёрнутое состояние - маленькая пилюля */
  width: 44px;
  height: 44px;
  /* Плавная анимация всех свойств */
  transition:
    width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
    border-radius 0.3s ease,
    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  position: relative;
}

/* Бургер-иконка в центре */
.rail-burger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* Быстрое исчезновение бургера */
  transition:
    opacity 0.15s ease-out,
    transform 0.2s ease-out;
}

.rail-burger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--rail-text);
  /* Adapted */
  border-radius: 2px;
  transition: all 0.15s ease;
}

/* Скрываем бургер БЫСТРО при наведении */
.left-rail-wrap:hover .rail-burger {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
  pointer-events: none;
}

/* При наведении - раскрытие панели */
.left-rail-wrap:hover .left-rail-bg {
  /* Форма раскрытой панели - прямоугольник с мягкими углами */
  border-radius: 16px;
  width: 72px;
  /* Высота подстраивается под содержимое */
  height: fit-content;
  padding: 14px 8px;
  justify-content: flex-end;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

/* Скрываем все кнопки в свёрнутом состоянии */
.left-rail-bg .rail-inner .rail-btn {
  opacity: 0;
  transform: scale(0.8) translateY(8px);
  /* Плавный переход для скрытия */
  transition:
    opacity 0.3s ease-out,
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* При наведении показываем все кнопки */
.left-rail-wrap:hover .left-rail-bg .rail-inner .rail-btn {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Плавное каскадное появление кнопок с задержкой */
.left-rail-wrap:hover .left-rail-bg .rail-inner .rail-btn:nth-child(1) {
  transition-delay: 0.08s;
}

.left-rail-wrap:hover .left-rail-bg .rail-inner .rail-btn:nth-child(2) {
  transition-delay: 0.14s;
}

.left-rail-wrap:hover .left-rail-bg .rail-inner .rail-btn:nth-child(3) {
  transition-delay: 0.2s;
}

.left-rail-wrap:hover .left-rail-bg .rail-inner .rail-btn:nth-child(4) {
  transition-delay: 0.26s;
}

.left-rail-wrap:hover .left-rail-bg .rail-inner .rail-btn:nth-child(5) {
  transition-delay: 0.32s;
}

/* Скрываем rail-inner в свёрнутом виде */
.left-rail-bg .rail-inner {
  opacity: 0;
  transition: opacity 0.35s ease-in-out 0.05s;
}

.left-rail-wrap:hover .left-rail-bg .rail-inner {
  opacity: 1;
  transition-delay: 0.1s;
}

/* Устаревшие классы высоты - оставляем для обратной совместимости */
.left-rail-bg.rail-3-icons {
  height: 44px;
}

.left-rail-bg.rail-4-icons {
  height: 44px;
}

.left-rail-bg.rail-5-icons {
  height: 44px;
}

/* уменьшенный rail-inner: это контейнер кнопок */
.left-rail-bg .rail-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: flex-end;
}

/* кнопки */
.rail-btn {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: transparent;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--rail-text);
  /* Adapted */
  cursor: pointer;
  position: relative;
  transition: transform .12s ease, background .12s ease, color .12s ease;
}

.rail-btn:hover,
.rail-btn.active {
  transform: translateY(-3px);
  background: var(--rail-bg-hover);
  /* Adapted and variable based */
  color: #fff;
}

/* tooltip справа */
.rail-btn::after {
  content: attr(data-title);
  position: absolute;
  left: 82px;
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: rgba(20, 20, 20, 0.95);
  color: #ddd;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.rail-btn:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* LEFT SLIDING PANEL REMOVED */

/* если нужно - изменение позиции на мобильных */
@media (max-width: 900px) {
  .left-rail-wrap {
    left: 8px;
    bottom: 12px;
    top: auto;
  }

  .brand-title {
    display: none;
  }
}

/* Sub-navigation block under header */
.sub-nav {
  display: flex;
  flex-direction: row;
  gap: 16px;
  padding: 0 20px;
  margin: 10px 0 20px 0;
  align-items: center;
}

/* Button */
.add-content-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--accent);
  color: #000;
  border: 1px solid #B7B7B7;
  border-radius: 40px;
  padding: 4px 4px 4px 20px;
  font-weight: 300;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
  width: max-content;
  justify-content: space-between;
  gap: 80px;
}

.add-content-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #111;
  color: var(--accent);
  border-radius: 50%;
  width: 37px;
  height: 37px;
}

.plus-icon {
  width: 14px;
  height: 14px;
}

/* Pills Containers */
.subnav-pills {
  display: flex;
  align-items: center;
  background-color: #1A1A1A;
  border: 1px solid #313131;
  border-radius: 40px;
  padding: 4px;
  width: 100%;
  justify-content: space-between;
}

.subnav-pill {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 300;
  padding: 8px 30px;
  border-radius: 30px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.subnav-pill:hover {
  color: #fff;
}

.subnav-pill.active {
  background-color: var(--bg-active);
  color: #fff;
  border: 1px solid var(--border-active);
}

/* Color overrides for Peak / Growth / Decline tabs */
.subnav-pill.tab[data-tab="peak"] {
  color: #A3FF91;
}

.subnav-pill.tab[data-tab="growth"] {
  color: #76CBFF;
}

.subnav-pill.tab[data-tab="decline"] {
  color: #FF9191;
}

/* Color overrides for Nodes tabs */
.subnav-pill.tab[data-tab="generation"] {
  color: #E0A3FF;
}

.subnav-pill.tab[data-tab="processing"] {
  color: #FFD166;
}

.subnav-pill.tab[data-tab="animation"] {
  color: #4DFFC9;
}

/* Search Container */
.subnav-search-container {
  margin-left: auto;
}

.subnav-search {
  display: flex;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid #313131;
  border-radius: 40px;
  padding: 6px 8px 6px 16px;
  gap: 10px;
  min-width: 260px;
}

.subnav-search-icon {
  color: var(--muted);
}

.subnav-search-input {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 300;
  outline: none;
  flex: 1;
}

.subnav-search-input::placeholder {
  color: var(--muted);
}

.subnav-filter-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--accent);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.subnav-filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Responsive header and chips (Extracted from templates) */
@media (max-width: 900px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .header-center {
    width: 100%;
    order: 3;
  }

  .header-right {
    order: 2;
    margin-left: auto;
  }

  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-right: 20px;
  }

  .chips::-webkit-scrollbar {
    display: none;
  }
}

/* Header Copy button Icon */
.btn-copy-header {
  background: var(--border-weak);
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.1s ease;
  min-width: 32px;
  min-height: 32px;
}

.btn-copy-header:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.05);
}

.btn-copy-header:active {
  transform: scale(0.95);
}

.btn-copy-header img {
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.btn-copy-header:hover img {
  opacity: 1;
}

/* DROPDOWN MENU ----------------------------------------- */
.profile-menu-container {
  position: relative;
  display: inline-block;
  z-index: 1050;
}

/* The Hamburger Circle Button */
.profile-menu-trigger {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border-weak);
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, border-radius 0.2s ease;
  position: relative;
  z-index: 1002;
  padding: 0;
}

.profile-menu-trigger:hover {
  background: var(--border-weak);
}

/* When the menu is OPEN, the trigger's bottom becomes flat and merges with dropdown */
.profile-menu-container.show .profile-menu-trigger {
  background: #131313e3;
  backdrop-filter: blur(10px);
  border-color: var(--panel);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border: 1px solid #313131;
  border-bottom: none;
}

.hamburger-icon {
  color: var(--text);
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% - 1px);
  right: 0;
  width: 250px;
  background: #131313e3;
  backdrop-filter: blur(10px);
  border: 1px solid var(--panel);
  border-radius: 30px 0 30px 30px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0px 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 1001;
  transform-origin: top right;
  transform: scale(0.95);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  border: 1px solid #313131;
}

.profile-menu-container.show .profile-dropdown {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  color: #9F9F9F;
  text-decoration: none;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 400;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  width: 87%;
  text-align: left;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.dropdown-icon {
  color: var(--muted);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.logout-item {
  color: #993737;
}

.logout-item .dropdown-icon {
  color: #993737;
}

.logout-item:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* Footer area for triggers */
.dropdown-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  /* margin-top: 6px; */
  padding: 10px 14px 12px 14px;
  border-top: 1px solid var(--border);
}

/* Tweaks for language and theme toggles in dropdown */
.dropdown-footer .menu-toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* specific resets for elements injected by our JS */
.dropdown-footer .lang-toggle-btn {
  background: #383838 !important;
  border: 1px solid #464646 !important;
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  color: #FFFFFF !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 0 !important;
  transition: background 0.2s ease, transform 0.2s ease !important;
}

.dropdown-footer .lang-toggle-btn:hover {
  background: #464646 !important;
}

/* Slider styles now generalized globally for all .theme-toggle-btn instances */