/* ============================================================
   R101: Header Redesign - Clean, Polished, Fully Responsive
   Structure: [Sidebar Toggle] [Brand] [Nav] [Utilities]
   ============================================================ */

/* ===== BASE HEADER ===== */
.app-header {
  height: 56px;
  padding: 0 20px;
  gap: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}

.app-header::after { display: none; }

/* Sidebar toggle */
.app-header .sidebar-toggle-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.app-header .sidebar-toggle-btn:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary);
}

/* Brand */
.app-header .brand { flex-shrink: 0; gap: 10px; }
.app-header .brand .logo { width: 28px; height: 28px; flex: 0 0 28px; }
.app-header .brand-text .name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}
.app-header .brand-text .sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

/* Header Nav (quick tabs + ecosystem) */
.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  flex-wrap: nowrap;
}

.header-quick-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.header-quick-tabs .header-tab-btn,
.header-eco-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.header-quick-tabs .header-tab-btn:hover,
.header-eco-link:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.1);
}
.header-quick-tabs .header-tab-btn.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: rgba(124,92,255,0.25);
}
.header-quick-tabs .header-tab-btn span:first-child { font-size: 14px; }

/* Ecosystem links */
.header-ecosystem {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}
.header-eco-link .eco-text { font-size: 11px; }
.header-eco-link { padding: 0 6px; }

/* Utilities bar */
.header-utilities {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Icon buttons (search, settings, theme, help) */
.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.header-icon-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.1);
}

/* Search kbd shortcut */
.header-search-kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  font-size: 10px;
  font-family: inherit;
  color: var(--text-muted);
  line-height: 1.4;
  pointer-events: none;
}

/* Theme toggle specifics */
.header-icon-btn.theme-toggle-btn { gap: 2px; }
.header-icon-btn .theme-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.header-icon-btn .theme-icon:not(.theme-icon-auto) { display: none; }

/* Settings dropdown */
.settings-menu-container { position: relative; }
.settings-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--surface-elevated);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  z-index: 2000;
}
.settings-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: left;
}
.settings-menu-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}
.settings-menu-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 6px;
}

/* Focus visible */
.header-icon-btn:focus-visible,
.header-tab-btn:focus-visible,
.header-eco-link:focus-visible,
.settings-menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 6px;
}

/* Active press state */
.header-icon-btn:active,
.header-tab-btn:active,
.header-eco-link:active {
  transform: scale(0.96);
}

/* ===== DESKTOP WIDE (1280px+) ===== */
@media (min-width: 1280px) {
  .app-header { padding: 0 28px; }
  .header-quick-tabs { gap: 4px; }
  .header-ecosystem { gap: 2px; }
}

/* ===== DESKTOP COMPACT (1024px - 1280px) ===== */
@media (max-width: 1280px) {
  .header-eco-link .eco-text { display: none; }
  .header-ecosystem .header-eco-link { padding: 0 8px; }
  .header-search-kbd { display: none; }
}

/* ===== TABLET (768px - 1024px) ===== */
@media (max-width: 1024px) {
  .app-header { padding: 0 16px; gap: 12px; }

  .header-quick-tabs .header-tab-btn { padding: 0 8px; font-size: 12px; height: 30px; }

  .header-ecosystem .eco-text { display: none; }
  .header-ecosystem .header-eco-link { padding: 0 6px; }

  .header-icon-btn .themeLabel { display: none; }

  .header-search-kbd { display: none; }
}

/* ===== SMALL TABLET (900px max) ===== */
@media (max-width: 900px) {
  .app-header { gap: 10px; }

  .header-quick-tabs { display: none; }

  .app-header .brand-text .sub { display: none; }
}

/* ===== MOBILE (<768px) ===== */
@media (max-width: 768px) {
  .app-header {
    height: 50px;
    padding: 0 12px;
    gap: 8px;
  }

  .app-header .brand { gap: 8px; flex: 1; min-width: 0; }
  .app-header .brand .logo { width: 24px; height: 24px; flex: 0 0 24px; }
  .app-header .brand-text .name { font-size: 14px; }
  .app-header .brand-text .sub { display: none; }

  .header-nav { display: none; }

  .header-utilities { gap: 2px; }

  .header-icon-btn {
    height: 36px;
    min-width: 36px;
    padding: 0;
    border-radius: 8px;
  }

  .header-icon-btn .theme-label { display: none; }
  .header-search-kbd { display: none; }

  .app-header #helpBtn { display: none; }

  .sidebar-toggle-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 16px;
  }
}

/* ===== SMALL MOBILE (<400px) ===== */
@media (max-width: 400px) {
  .app-header {
    height: 48px;
    padding: 0 8px;
    gap: 6px;
  }

  .app-header .brand { gap: 6px; }
  .app-header .brand .logo { width: 22px; height: 22px; flex: 0 0 22px; }
  .app-header .brand-text .name { font-size: 13px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .header-icon-btn {
    height: 34px;
    min-width: 34px;
  }

  .sidebar-toggle-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-width: 768px) and (orientation: landscape) {
  .app-header { height: 44px; }
}

.app-header .sidebar-toggle-btn {
  display: flex;
}

/* ===== LIGHT THEME ===== */
.theme-light .app-header {
  background: rgba(255,255,255,0.92);
  border-bottom-color: rgba(0,0,0,0.08);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.theme-light .header-quick-tabs .header-tab-btn:hover,
.theme-light .header-eco-link:hover,
.theme-light .header-icon-btn:hover {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.08);
}
.theme-light .header-quick-tabs .header-tab-btn.active {
  background: rgba(108,71,255,0.1);
  color: var(--accent);
  border-color: rgba(108,71,255,0.2);
}
.theme-light .sidebar-toggle-btn {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
}
.theme-light .header-search-kbd {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.1);
  color: var(--text-muted);
}
.theme-light .settings-menu-dropdown {
  background: #fff;
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}
.theme-light .settings-menu-item:hover {
  background: rgba(0,0,0,0.04);
}