/* ===========================================
   JAVY 5 - Header Bar (Chappy AI V2 Style)
   3D Glass Buttons, Shimmer Logo, Inset Shadows
   =========================================== */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(56px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 20px 0;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  gap: var(--space-xl);
  flex-shrink: 0;
}

/* Glass shine overlay on header */
#header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--glass-shine);
  pointer-events: none;
  z-index: 0;
}

/* All direct children above shine */
#header > * {
  position: relative;
  z-index: 1;
}

/* ---- Left Section: Logo ---- */
.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

#header .logo {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #c4b5fd 0%, #67e8f9 50%, #f9a8d4 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  user-select: none;
  cursor: default;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  to { background-position: 200% center; }
}

/* ---- Center Section: Search Bar ---- */
.header-center {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-bar {
  display: flex;
  align-items: center;
  width: 100%;
  height: 38px;
  padding: 0 14px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  gap: var(--space-sm);
  box-shadow:
    var(--shadow-inset),
    0 1px 3px rgba(0, 0, 0, 0.2);
}

.search-bar:focus-within {
  border-color: var(--accent-purple);
  box-shadow:
    0 0 0 2px rgba(139, 92, 246, 0.2),
    0 0 12px rgba(139, 92, 246, 0.1),
    var(--shadow-inset);
}

.search-bar .search-icon,
.search-bar .search-icon svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  height: 100%;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-family);
}

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

.search-bar .search-shortcut {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  display: none;
}

@media (min-width: 640px) {
  .search-bar .search-shortcut {
    display: block;
  }
}

/* ---- Right Section: Action Buttons ---- */
.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ---- Header Button (3D Glass, groß & bold) ---- */
.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-spring);
  box-shadow:
    var(--shadow-sm),
    var(--shadow-inset),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.header-btn:hover {
  transform: translateY(-2px);
  color: var(--text-primary);
  border-color: var(--glass-border-hover);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.4),
    var(--shadow-inset);
}

.header-btn:active {
  transform: translateY(0);
  box-shadow:
    var(--shadow-sm),
    var(--shadow-inset);
}

.header-btn.active {
  color: var(--accent-purple);
  border-color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.12);
  box-shadow:
    0 0 12px rgba(139, 92, 246, 0.2),
    var(--shadow-inset);
}

.header-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.header-btn svg,
.header-btn i svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
}

.header-btn i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.header-btn .btn-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-error);
  border: 2px solid var(--bg-dark);
}

/* ---- Header Divider ---- */
.header-divider {
  width: 1px;
  height: 24px;
  background: var(--glass-border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ---- Mobile-only elements (hidden on desktop) ---- */
.mobile-only {
  display: none !important;
}

/* ---- Mobile ---- */
@media (max-width: 639px) {
  #header {
    height: calc(46px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 10px 0;
    gap: 4px;
  }

  /* Show mobile-only elements */
  .mobile-only {
    display: inline-flex !important;
  }

  /* Search: hide full bar, show toggle button instead */
  .header-center {
    display: none;
  }

  /* Hide text in AI button on mobile */
  #btn-chat span {
    display: none;
  }

  .header-btn {
    padding: 7px;
    font-size: 12px;
    border-radius: 8px;
  }

  .header-btn svg,
  .header-btn i svg {
    width: 16px;
    height: 16px;
  }

  .header-right {
    gap: 4px;
  }

  .header-divider {
    height: 20px;
    margin: 0 2px;
  }

  #header .logo {
    font-size: 17px;
  }

  /* Mobile search overlay (when open) */
  .header-center.mobile-open {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    max-width: none;
    padding: env(safe-area-inset-top, 0px) 10px 0;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    z-index: 10;
    align-items: center;
    gap: 8px;
  }

  .header-center.mobile-open .search-bar {
    height: 34px;
  }
}
