/* ── App Layout (Vertical Stack) ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Tab Navigation Bar ── */
.tab-nav {
  height: var(--tab-nav-height);
  min-height: var(--tab-nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

/* Left: Logo */
.tab-nav-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.tab-nav-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.tab-nav-logo .logo-icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
  flex-shrink: 0;
}

.tab-nav-logo .logo-text {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.tab-nav-hamburger {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.tab-nav-hamburger:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Center: Tabs */
.tab-nav-center {
  display: flex;
  align-items: center;
  height: 100%;
  gap: var(--sp-1);
}

.tab-item {
  position: relative;
  padding: 0 var(--sp-4);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.tab-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.2s ease;
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  color: var(--accent);
}

.tab-item.active::after {
  width: calc(100% - 16px);
}

.chevron-icon {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.tab-group.open .chevron-icon {
  transform: rotate(180deg);
}

/* Tab Group (Dropdown) */
.tab-group {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.tab-group-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 160px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  display: none;
  z-index: 500;
}

.tab-group.open .tab-group-dropdown {
  display: block;
  animation: dropdownIn 0.2s ease-out;
}

.tab-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.tab-dropdown-item:hover {
  background: var(--bg-hover);
}

.tab-dropdown-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Right: Tools */
.tab-nav-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

/* ── TopNav Shared Styles (Search, Icons, User) ── */
.topnav-search {
  position: relative;
}

.topnav-search input {
  height: 32px;
  width: 180px;
  padding: 0 var(--sp-3) 0 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: var(--text-xs);
  outline: none;
  transition: border-color 0.2s ease, width 0.2s ease, box-shadow 0.2s ease;
}

.topnav-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  width: 240px;
}

.topnav-search input::placeholder {
  color: var(--text-muted);
}

.topnav-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.topnav-icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.topnav-icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.topnav-icon-btn svg {
  width: 18px;
  height: 18px;
}

.topnav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.topnav-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.topnav-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
}

.user-name {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── Content Area ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  background: var(--bg-primary);
}

/* ── Mobile Menu Panel ── */
.mobile-menu-panel {
  display: none;
  flex-direction: column;
  padding: var(--sp-3) var(--sp-4);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  z-index: 99;
}

.mobile-menu-panel.open {
  display: flex;
  animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.mobile-menu-item {
  display: block;
  width: 100%;
  padding: 10px var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.mobile-menu-item:hover {
  background: var(--bg-hover);
}

.mobile-menu-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

.mobile-menu-divider {
  height: 1px;
  background: var(--divider);
  margin: var(--sp-2) 0;
}

.mobile-menu-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Project Switcher (Content Area) ── */
.project-switcher {
  position: relative;
}

.project-switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.project-switcher-btn:hover {
  background: var(--bg-active);
  border-color: var(--accent);
}

.project-switcher-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.project-switcher-btn .chevron {
  width: 12px;
  height: 12px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.project-switcher.open .chevron {
  transform: rotate(180deg);
}

.project-switcher-name {
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-switcher-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 240px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 500;
}

.project-switcher-dropdown.show {
  display: block;
  animation: dropdownIn 0.2s ease-out;
}

.project-switcher-item {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: background 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-switcher-item:hover {
  background: var(--bg-hover);
}

.project-switcher-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

.project-switcher-item-code {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Responsive (< 768px) ── */
@media (max-width: 768px) {
  .tab-nav-center { display: none; }
  .tab-nav-hamburger { display: flex; }
  .topnav-search, .topnav-divider, .user-name { display: none; }
  .tab-nav { padding: 0 var(--sp-4); }
  .content { padding: var(--sp-4); }
}

@media (min-width: 769px) {
  .mobile-menu-panel { display: none !important; }
}
