/* SD_HAUS 統一系統標頭（nav.app-chrome.app-header）— 所有頁面共用的單一來源。
   設計語彙與 markup 範本見 .claude/ops/ui-principles.md §2「標頭」；頁面不得在本地重寫這些 class。
   色彩只用 theme token；.app-chrome 會把 token 換成深色階，所以 11 套主題下標頭都維持深色。 */

:root { --app-header-h: 64px; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    flex: 0 0 auto;
    width: 100%;
    height: var(--app-header-h);
    display: flex;
    align-items: center;
    background: rgb(var(--c-black) / .8);
    border-bottom: 1px solid rgb(var(--c-zinc-800));
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}
/* 首頁殼層的標頭固定在視窗頂端，內容以 pt-16 讓位 */
.app-header.app-header-fixed { position: fixed; top: 0; left: 0; right: 0; }

.app-header-inner {
    width: 100%;
    min-width: 0;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.app-header-brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.app-header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
/* 放不下才換行（2026-11-25 使用者選定）：app_header.js 判斷路徑或動作鈕在一列放不下時加 .app-header-stacked，
   路徑獨佔第一列、動作鈕整列換到第二行靠右；放得下時維持一列 64px。實高寫入 --app-header-live-h。 */
.app-header.app-header-stacked { height: auto; min-height: var(--app-header-h); }
.app-header-stacked .app-header-inner { flex-wrap: wrap; row-gap: 8px; }
.app-header-stacked .app-header-brand { flex: 1 0 100%; }
.app-header-stacked .app-header-actions { flex-wrap: wrap; justify-content: flex-end; margin-left: auto; max-width: 100%; }
@media (min-width: 768px) { .app-header-stacked .app-header-inner { padding-top: 10px; padding-bottom: 10px; } }
/* 本檔晚於 tailwind.css 載入，display:flex 會蓋過 Tailwind 的 .hidden；標頭內一律讓 .hidden 生效。 */
.app-header .hidden { display: none; }

/* ── 標誌：主色方塊＋手繪稿線 3D 建築（/shared/app_logo.js）；未載入時顯示 SVG ── */
.app-brand-mark {
    position: relative;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: var(--on-brand);
    transition: background-color .15s ease, box-shadow .15s ease;
}
.app-brand-mark:hover { box-shadow: 0 0 0 3px rgb(var(--c-brand) / .28); }
.app-brand-mark:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.app-brand-mark > svg { width: 20px; height: 20px; }
.app-brand-mark.is-3d > svg { display: none; }
.app-brand-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ── 路徑（breadcrumb）：SD_HAUS Architects -模組 / 案件 / 子頁 ──
   分隔符號由 CSS 產生（螢幕閱讀器不念）；最後一層是目前頁面（aria-current，不可點）。 */
.app-breadcrumb {
    display: flex;
    align-items: center;
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1.25;
    white-space: nowrap;
}
.app-crumb-item { display: flex; align-items: center; min-width: 0; flex: 0 1 auto; }
.app-crumb-item:first-child { flex: 0 0 auto; }
.app-crumb-item + .app-crumb-item::before {
    content: "/";
    flex: 0 0 auto;
    margin: 0 .45em;
    color: var(--ink-dim);
    font-weight: 500;
}
.app-crumb-item.app-crumb-module::before { content: "-"; margin: 0 0 0 .3em; color: inherit; font-weight: 700; }
/* 空間不夠時只縮案件名稱；模組名稱與目前頁面不縮（各自最多佔近一半寬度，超過才省略）。 */
.app-crumb-item.app-crumb-module { flex-shrink: 0; max-width: 45%; }
.app-crumb-item:last-child:not(:first-child) { flex-shrink: 0; max-width: 50%; }

.app-crumb {
    display: block;
    min-width: 0;
    max-width: 18em;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgb(var(--c-zinc-300));
    text-decoration: none;
    border-radius: 4px;
    transition: color .15s ease;
}
.app-crumb-project .app-crumb { max-width: 24em; }
.app-crumb-module { color: rgb(var(--c-zinc-300)); }
.app-crumb-home { max-width: none; color: var(--ink); }
.app-crumb-accent { color: var(--brand); text-transform: uppercase; }
.app-crumb[aria-current="page"], .app-crumb-item:has(> [aria-current="page"]) { color: var(--ink); }
a.app-crumb:hover { color: var(--brand); }
a.app-crumb-home:hover .app-crumb-accent { color: var(--brand-light); }
a.app-crumb:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── 右側：線上人數、通知、個人資料按鈕 ── */
.app-user-nav { display: flex; align-items: center; gap: 8px; }
.app-online {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgb(239 68 68 / .1);
    border: 1px solid rgb(239 68 68 / .3);
    color: #ef4444;
    font-size: 12px;
    font-weight: 700;
}
.app-online-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; flex: 0 0 auto; }
.app-icon-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: var(--ink-dim);
    transition: color .15s ease, background-color .15s ease;
}
.app-icon-btn:hover { color: var(--brand); background: rgb(var(--c-zinc-800) / .7); }
.app-icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.app-icon-btn svg { width: 20px; height: 20px; }
.app-icon-badge {
    position: absolute;
    top: 5px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid rgb(var(--c-zinc-950));
}

/* 個人資料按鈕：膠囊外框 40px、內距 3px，32px 大頭貼與左端圓弧同心（不會脫開）。 */
.app-profile { position: relative; flex: 0 0 auto; }
.app-profile-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    max-width: 220px;
    padding: 3px 12px 3px 3px;
    border-radius: 999px;
    border: 1px solid rgb(var(--c-zinc-800));
    background: rgb(var(--c-zinc-900));
    color: rgb(var(--c-zinc-200));
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}
.app-profile-trigger:hover, .app-profile-trigger[aria-expanded="true"] { border-color: var(--brand); }
.app-profile-trigger:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.app-profile-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-profile-caret { width: 14px; height: 14px; flex: 0 0 auto; color: var(--ink-dim); transition: transform .15s ease; }
.app-profile-trigger[aria-expanded="true"] .app-profile-caret { transform: rotate(180deg); color: var(--brand); }

.app-avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: var(--on-brand);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}
.app-avatar > img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 50%; }
.app-avatar-lg { width: 44px; height: 44px; font-size: 18px; }

.app-profile-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 60;
    width: 240px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgb(var(--c-zinc-800));
    background: rgb(var(--c-zinc-900));
    box-shadow: 0 18px 40px rgb(0 0 0 / .45);
}
.app-profile-menu[hidden] { display: none; }
.app-profile-card { display: flex; align-items: center; gap: 12px; padding: 10px; margin-bottom: 6px; border-bottom: 1px solid rgb(var(--c-zinc-800)); }
.app-profile-card-name { color: var(--ink); font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-profile-card-role { color: var(--ink-dim); font-size: 12px; margin-top: 2px; }
.app-profile-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 8px;
    color: rgb(var(--c-zinc-200));
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    transition: color .15s ease, background-color .15s ease;
}
.app-profile-item svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--ink-dim); transition: color .15s ease; }
.app-profile-item:hover, .app-profile-item:focus-visible { background: rgb(var(--c-zinc-800) / .7); color: var(--ink); outline: none; }
.app-profile-item:hover svg, .app-profile-item:focus-visible svg { color: var(--brand); }
.app-profile-item.is-danger:hover, .app-profile-item.is-danger:focus-visible,
.app-profile-item.is-danger:hover svg, .app-profile-item.is-danger:focus-visible svg { color: #ef4444; }

/* ── 窄螢幕：品牌字改由標誌代表，只留模組以後的路徑；名字收進選單 ── */
/* 頁面動作鈕放不下時整列換到第二行（不出現橫向捲動）；首頁殼層以 --shell-header-h 量實際高度讓位。 */
@media (max-width: 767px) {
    .app-header { height: auto; min-height: var(--app-header-h); }
    .app-header-inner { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
    .app-header-actions { flex-wrap: wrap; justify-content: flex-end; margin-left: auto; max-width: 100%; }
    .app-crumb-item:first-child { display: none; }
    .app-crumb-item.app-crumb-module::before { content: none; }
    .app-breadcrumb { font-size: 15px; }
    .app-profile-name, .app-profile-caret { display: none; }
    .app-profile-trigger { padding: 3px; }
    .app-online { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .app-brand-mark, .app-crumb, .app-icon-btn, .app-profile-trigger, .app-profile-caret, .app-profile-item, .app-profile-item svg { transition: none; }
}

@media print {
    .app-header { display: none !important; }
}
