/* =====================================================================
   Pipelet Header (app-header + prefs-dropdown)
   Uses emp-portal's pipelet-theme.css variables. Mirrors the layout
   of sim.pipelet.com / studio.pipelet.com so the header is consistent
   across the Pipelet suite.
   ===================================================================== */

#app-header {
    background: var(--bg-glass, rgba(255, 255, 255, 0.82));
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: var(--text-primary);
    padding: 0 var(--sp-7);
    height: 56px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-subtle);
}
#app-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #c49a6c, var(--accent) 50%, #c49a6c);
}
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    gap: var(--sp-4);
}
.header-left {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
}
.header-icon {
    width: 22px;
    height: 22px;
    color: var(--text-primary);
    flex-shrink: 0;
}
#app-header a.header-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-4);
    color: inherit;
    text-decoration: none;
}
#app-header h1 {
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
}
#app-header h1 em { font-style: italic; font-weight: 700; }
.header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    flex-wrap: wrap;
}
#app-header nav {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
}
.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}
.nav-link.active {
    color: var(--text-primary);
    background: var(--bg-surface-active);
    font-weight: 600;
}

/* ---- Prefs dropdown (user info / language / theme) ---- */
.prefs-dropdown { position: relative; flex-shrink: 0; }
.prefs-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    font-family: inherit;
}
.prefs-toggle:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-normal);
}
.prefs-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 240px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--elevation-3);
    z-index: 1000;
    padding: 6px 0;
    display: none;
}
.prefs-menu.open { display: block; }
.prefs-section { padding: 2px 0; }
.prefs-section-label {
    padding: 4px 14px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-disabled);
}
.prefs-section-user { padding: 8px 14px; }
.prefs-user-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}
.prefs-user-label {
    font-size: var(--text-xs);
    color: var(--text-disabled);
    margin-top: 2px;
}
.prefs-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}
.prefs-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 7px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: left;
    transition: background 0.1s, color 0.1s;
    font-family: inherit;
}
.prefs-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}
.prefs-item.active {
    color: var(--text-primary);
    font-weight: 600;
}
.prefs-item.active::after {
    content: "\2713";
    margin-left: auto;
    font-size: 0.85em;
    color: var(--accent);
}

/* ---- Dark mode overrides ---- */
html[data-theme="dark"] {
    --bg-solid: #1a1d21;
    --bg-secondary: #232629;
    --bg-tertiary: #2b2e32;
    --bg-gradient: linear-gradient(180deg, #1a1d21 0%, #232629 100%);
    --bg-gradient-sub: linear-gradient(180deg, #1f2226 0%, #1a1d21 100%);
    --bg-surface: #232629;
    --bg-surface-hover: rgba(255, 255, 255, 0.05);
    --bg-surface-active: rgba(255, 255, 255, 0.08);
    --bg-glass: rgba(26, 29, 33, 0.82);
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.70);
    --text-disabled: rgba(255, 255, 255, 0.40);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-normal: rgba(255, 255, 255, 0.13);
}
html[data-theme="dark"] body { color: var(--text-primary); }

@media (max-width: 720px) {
    #app-header { padding: 0 var(--sp-4); height: auto; min-height: 56px; }
    #app-header nav { display: none; }
}
