/*
 * Terminal43 Code - Top Bar Component
 * Slim 52px bar with breadcrumbs, search, notifications, user menu
 */

/* ============================================
   TOP BAR CONTAINER
   ============================================ */

.app-topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ============================================
   LEFT: TOGGLE + BREADCRUMBS
   ============================================ */

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

/* Sidebar toggle button */
.topbar-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.topbar-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.topbar-toggle svg {
  width: 20px;
  height: 20px;
}

/* Hide toggle on mobile (use mobile nav instead) */
@media (min-width: 1025px) {
  .layout-fullwidth .topbar-toggle,
  .layout-learning .topbar-toggle {
    display: none;
  }
}

/* Breadcrumbs */
.topbar-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
}

.topbar-breadcrumb {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}

.topbar-breadcrumb:hover {
  color: var(--primary);
}

.topbar-breadcrumb.current {
  color: var(--text);
  font-weight: 600;
  pointer-events: none;
}

.topbar-breadcrumb-sep {
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 0.75rem;
}

/* ============================================
   CENTER: SEARCH BAR
   ============================================ */

.topbar-center {
  flex: 0 1 420px;
  max-width: 420px;
}

.topbar-search {
  position: relative;
  width: 100%;
}

.topbar-search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: all 0.2s;
}

.topbar-search-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--bg-card);
}

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

.topbar-search-input {
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  color: var(--text);
  width: 100%;
  outline: none;
  font-family: var(--font);
}

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

.topbar-search-kbd {
  padding: 2px 6px;
  font-size: 0.625rem;
  font-family: var(--font);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Search suggestions dropdown */
.topbar-search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 1000;
  max-height: 360px;
  overflow-y: auto;
}

.topbar-search-suggestions.active {
  display: block;
}

.topbar-search-suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
}

.topbar-search-suggestion:hover,
.topbar-search-suggestion.selected {
  background: var(--bg-subtle);
}

.topbar-search-suggestion-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.topbar-search-suggestion-text {
  flex: 1;
  min-width: 0;
}

.topbar-search-suggestion-title {
  font-weight: 600;
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-search-suggestion-type {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ============================================
   RIGHT: ACTIONS
   ============================================ */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Icon button */
.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  position: relative;
  text-decoration: none;
}

.topbar-icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.topbar-icon-btn.active {
  background: var(--primary-light);
  color: var(--primary);
}

.topbar-icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Notification badge */
.topbar-notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: white;
  font-size: 0.5625rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-card);
}

/* Theme toggle in topbar */
.topbar-theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.topbar-theme-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.topbar-theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* User avatar dropdown */
.topbar-user {
  position: relative;
}

.topbar-user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-full);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.topbar-user-trigger:hover {
  background: var(--bg-subtle);
}

.topbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8125rem;
}

.topbar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-user-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.topbar-user.open .topbar-user-chevron {
  transform: rotate(180deg);
}

/* User dropdown menu */
.topbar-user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 1001;
  padding: 8px 0;
}

.topbar-user.open .topbar-user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.topbar-user-dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.topbar-user-dropdown-name {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text);
}

.topbar-user-dropdown-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-user-dropdown-plan {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.625rem;
  font-weight: 700;
  margin-top: 6px;
}

.topbar-user-dropdown-plan.pro {
  background: var(--primary-gradient);
  color: white;
}

.topbar-user-dropdown-plan.pro_plus {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
}

.topbar-user-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.1s;
}

.topbar-user-dropdown a:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.topbar-user-dropdown a svg {
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.topbar-user-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.topbar-user-dropdown a.danger {
  color: var(--danger);
}

.topbar-user-dropdown a.danger:hover {
  background: var(--danger-light);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .topbar-center {
    display: none;
  }

  .topbar-user-name {
    display: none;
  }

  .topbar-breadcrumbs {
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .app-topbar {
    padding: 0 12px;
    gap: 8px;
  }

  .topbar-breadcrumbs {
    display: none;
  }
}
