/* App-shell: меню и нижняя плашка (только new.svoim-i.ru / templates_new) */

body.has-app-shell {
  padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
}

body.has-app-shell .container {
  max-width: 480px;
}

/* ——— Верхнее меню разделов ——— */
.app-main-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.35rem;
  margin: 0 0 0.65rem;
  background: rgba(15, 23, 42, 0.55);
  border-radius: 16px;
  border: 1px solid rgba(51, 65, 85, 0.45);
}

.app-main-tabs::-webkit-scrollbar {
  display: none;
}

.app-main-tabs .tab-link {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 4.5rem;
  min-height: 4.25rem;
  padding: 0.5rem 0.65rem;
  border-radius: 14px;
  border: 1px solid rgba(100, 116, 139, 0.35);
  background: rgba(30, 41, 59, 0.5);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

.app-main-tabs .tab-link .app-tab-icon {
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(14, 165, 233, 0.12);
  color: #38bdf8;
  flex-shrink: 0;
}

.app-main-tabs .tab-link .app-tab-icon img {
  width: 1.35rem;
  height: 1.35rem;
  object-fit: contain;
}

.app-main-tabs .tab-link .app-tab-icon svg {
  width: 1.35rem;
  height: 1.35rem;
}

.app-main-tabs .tab-link.active .app-tab-icon,
.app-main-tabs .tab-link[aria-selected="true"] .app-tab-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.app-main-tabs .tab-link.active,
.app-main-tabs .tab-link[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(145deg, #0ea5e9 0%, #0284c7 55%, #7c3aed 100%);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
}

/* Скрываем старый вид табов внутри app-shell */
.dashboard-tabs-stack .tabs:not(.app-main-tabs) {
  display: none;
}

/* Подменю */
.app-subnav {
  margin: 0 0 0.85rem;
  padding: 0.5rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(51, 65, 85, 0.4);
}

.app-subnav .subscription-section-nav-inner {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.app-subnav .subscription-section-nav-inner::-webkit-scrollbar {
  display: none;
}

.app-subnav .subscription-section-nav-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

.app-subnav .subscription-section-nav-link::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #0ea5e9;
  opacity: 0.7;
  flex-shrink: 0;
}

.subscription-section-nav.app-subnav {
  border-top: none;
  border-radius: 14px;
}

.dashboard-tabs-stack--sub .app-main-tabs {
  border-radius: 16px 16px 0 0;
  margin-bottom: 0;
}

.dashboard-tabs-stack--sub .app-subnav.subscription-section-nav {
  border-radius: 0 0 16px 16px;
  margin-bottom: 0.85rem;
  border-top: 1px solid rgba(14, 165, 233, 0.15);
}

/* Старый footer-карточка: кнопки скрыты, push в sheet */
body.has-app-shell .user-card-buttons {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.has-app-shell .user-card:not(.js-push-section) {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

body.has-app-shell .user-card:not(.js-push-section) .user-card-info {
  display: none;
}

body.has-app-shell .js-push-section {
  display: none;
}

/* ——— Нижняя плашка ——— */
.app-bottom-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  z-index: 900;
  width: 100%;
  max-width: 480px;
  padding: 0.4rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  pointer-events: none;
}

.app-bottom-bar-inner {
  pointer-events: auto;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: 0.25rem;
  padding: 0.35rem 0.25rem;
  border-radius: 20px 20px 0 0;
  background: rgba(13, 18, 32, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-bottom: none;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
}

.app-bottom-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.35rem 0.2rem;
  min-height: 3.25rem;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: #94a3b8;
  text-decoration: none;
  font-family: inherit;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s, transform 0.1s;
}

.app-bottom-item:active {
  transform: scale(0.94);
}

.app-bottom-item.is-active {
  color: #38bdf8;
}

.app-bottom-item-icon {
  position: relative;
  width: 1.65rem;
  height: 1.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-bottom-item-icon img {
  width: 1.5rem;
  height: 1.5rem;
  object-fit: contain;
}

.app-bottom-item-icon svg {
  width: 1.45rem;
  height: 1.45rem;
}

.app-bottom-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.5625rem;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
}

.app-bottom-badge.hidden {
  display: none;
}

/* Sheet «Ещё» */
.app-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.app-sheet-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.app-sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  bottom: 0;
  z-index: 960;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-bottom: none;
  padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}

.app-sheet-overlay.is-open .app-sheet {
  transform: translateX(-50%) translateY(0);
}

.app-sheet-handle {
  width: 2.5rem;
  height: 0.25rem;
  margin: 0 auto 0.85rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
}

.app-sheet-user {
  text-align: center;
  font-size: 0.8125rem;
  color: #94a3b8;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.app-sheet-user strong {
  color: #f1f5f9;
}

.app-sheet-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.app-sheet-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(51, 65, 85, 0.45);
  background: rgba(30, 41, 59, 0.55);
  color: #e2e8f0;
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.app-sheet-row:active {
  background: rgba(51, 65, 85, 0.65);
}

.app-sheet-row-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 165, 233, 0.15);
  flex-shrink: 0;
}

.app-sheet-row-icon img {
  width: 1.5rem;
  height: 1.5rem;
  object-fit: contain;
}

.app-sheet-row-icon svg {
  width: 1.35rem;
  height: 1.35rem;
  color: #38bdf8;
}

.app-sheet-row-arrow {
  margin-left: auto;
  color: #64748b;
  font-size: 1.125rem;
}

.app-sheet-push {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.4);
}

.app-sheet-push .section-title {
  font-size: 0.8125rem;
  margin-bottom: 0.65rem;
}

.app-sheet-danger {
  margin-top: 0.5rem;
  color: #f87171;
}

.app-sheet-danger .app-sheet-row-icon {
  background: rgba(239, 68, 68, 0.15);
}

.app-sheet-danger .app-sheet-row-icon svg {
  color: #f87171;
}

@media (min-width: 769px) {
  body.has-app-shell {
    padding-bottom: 1.5rem;
  }

  .app-bottom-bar {
    position: sticky;
    transform: none;
    left: auto;
    margin-top: 1.25rem;
    padding-bottom: 0;
  }

  .app-bottom-bar-inner {
    border-radius: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  }
}
