/* public/assets/css/layout_nav.css (V28.49.0 - PC Sidebar Header Fix) */

/* ============================ */
/* 1. Header (頂部導航列) */
/* ============================ */
.app-header {
    position: fixed;
    top: 0;
    right: 0;
    /* 修正 App 遮擋問題：Header 高度需包含 safe-area */
    height: calc(var(--header-height) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    background-color: var(--c-primary);
    color: #ffffff !important;
    z-index: 1040;
    /* 比 Sidebar (1050) 低 */
    display: flex;
    align-items: center;
    padding-left: 20px;
    padding-right: 20px;
    box-shadow: var(--shadow-soft);

    /* 預設 (Mobile): 佔滿全寬 */
    left: 0;
    width: 100%;
    transition: left 0.3s ease, width 0.3s ease;
}

/* PC 版 Header 定位覆寫 (螢幕 >= 769px) */
@media (min-width: 769px) {
    .app-header {
        /* Header 左側避開 Sidebar */
        left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }

    /* 當 PC 版收合時 */
    body.sb-collapsed .app-header {
        left: var(--sidebar-collapsed-width);
        width: calc(100% - var(--sidebar-collapsed-width));
    }
}

.header-content {
    display: flex;
    align-items: center;
    width: 100%;
}

.header-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    margin-right: 15px;
    color: #ffffff !important;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-title,
.app-title a {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff !important;
    text-decoration: none;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #ffffff !important;
}

.header-actions i {
    color: #ffffff !important;
}

/* ============================ */
/* 2. Sidebar (側邊選單) */
/* ============================ */
.sidebar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    z-index: 1050;
    /* 最高層級 */
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.3s ease;

    /* Mobile 預設隱藏 */
    transform: translateX(-100%);

    /* Mobile Sidebar 頂天立地，不需要 padding-top */
    padding-top: 0;
}

/* PC 版 Sidebar 邏輯 (統一使用 769px) */
@media (min-width: 769px) {
    .sidebar-wrapper {
        transform: translateX(0);
        /* 預設顯示 */
        /* PC Sidebar 內容也不需要 padding-top，因為 Header 在右側 */
        padding-top: 0;
    }

    /* 🚨 關鍵修正：強制隱藏 PC 版 Sidebar 內的標題與叉叉 */
    .sidebar-header-box {
        display: none !important;
    }

    /* PC 收合模式 */
    body.sb-collapsed .sidebar-wrapper {
        width: var(--sidebar-collapsed-width);
    }

    /* 收合時隱藏文字 */
    body.sb-collapsed .nav-link span,
    body.sb-collapsed .nav-group {
        display: none !important;
    }

    /* 收合時圖示置中 */
    body.sb-collapsed .nav-link {
        justify-content: center;
        padding: 0;
    }

    body.sb-collapsed .nav-link i {
        margin: 0;
    }
}

/* Mobile 展開狀態 (透過 JS 切換) */
.sidebar-wrapper.active,
body.sb-sidenav-toggled .sidebar-wrapper {
    transform: translateX(0);
}

/* Sidebar 內部 Header (僅 Mobile 顯示) */
.sidebar-header-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
    flex-shrink: 0;
}

.sidebar-header-box h3 {
    margin: 0;
    color: var(--text-main);
}

.close-btn {
    font-size: 24px;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.nav-group {
    padding: 15px 20px 5px;
    font-size: 0.85em;
    font-weight: bold;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-group.highlight {
    color: var(--c-brand-blue);
}

.nav-link {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 20px;
    color: var(--text-main);
    text-decoration: none;
    transition: 0.2s;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--c-brand-blue);
}

.nav-link.active {
    background-color: var(--bg-status-info);
    color: var(--c-brand-blue);
    border-right: 3px solid var(--c-brand-blue);
}

.nav-link i {
    width: 24px;
    text-align: center;
    margin-right: 15px;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.nav-link.active i {
    color: var(--c-brand-blue);
}

/* 遮罩層 (僅 Mobile) */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    display: none;
}

.sidebar-backdrop.active {
    display: block;
}

/* ============================ */
/* 3. Content Wrapper (主內容) */
/* ============================ */
.content-wrapper {
    padding: 2vw;
    /* 修正 App 遮擋問題：加入 safe-area-inset-top */
    padding-top: calc(var(--header-height) + 15px + env(safe-area-inset-top));
    min-height: 100vh;
    /* margin-bottom 改為 padding-bottom 以延伸背景色 */
    padding-bottom: 100px;
    margin-bottom: 0;

    transition: margin-left 0.3s ease;

    /* Mobile 預設 */
    margin-left: 0;
}

/* 🚨 Android WebView Fallback (當 env 失效時強制修正) */
html.platform-android .app-header {
    height: calc(var(--header-height) + 35px) !important;
    padding-top: 35px !important;
}

html.platform-android .content-wrapper {
    padding-top: calc(var(--header-height) + 15px + 35px) !important;
}

/* PC 版內容推擠 */
@media (min-width: 769px) {
    .content-wrapper {
        margin-left: var(--sidebar-width);
    }

    body.sb-collapsed .content-wrapper {
        margin-left: var(--sidebar-collapsed-width);
    }
}

/* ============================ */
/* 4. Mobile FAB & Others */
/* ============================ */
.mobile-fab-container {
    position: fixed;
    bottom: 30px;
    left: 20px;
    z-index: 990;
}

.fab-btn {
    background: var(--c-brand-green);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (min-width: 769px) {
    .mobile-fab-container {
        display: none;
    }
}

/* ============================ */
/* 5. Guide Box & Image Modal */
/* ============================ */
.guide-box {
    background: linear-gradient(to right, #e3f2fd, #f1f8e9);
    border: 1px solid #bbdefb;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Founder Theme - Light Mode */
.guide-box.founder-theme {
    background: linear-gradient(to right, #fff8e1, #ffecb3);
    border-color: #ffe0b2;
    border-left: 5px solid #FF9800;
    /* Distinct left border */
}

/* Dark Mode Overrides */
[data-theme="dark"] .guide-box {
    background: rgba(21, 101, 192, 0.2);
    /* Increased visibility */
    border-color: #1e3a5f;
    background-image: none;
    /* Remove gradient */
}

[data-theme="dark"] .guide-box.founder-theme {
    background: rgba(255, 152, 0, 0.2);
    /* Increased visibility */
    border-color: #5d4037;
    background-image: none;
    /* Remove gradient */
    border-left: 5px solid #E65100;
    /* Distinct left border in dark mode */
}

.guide-title {
    font-weight: bold;
    color: #1565C0;
    margin-bottom: 10px;
    display: flex;
    gap: 8px;
}

/* Founder Title - Custom Class to remove inline styles */
.founder-title {
    margin: 0;
    color: #E65100;
    font-size: 1.1rem;
}

[data-theme="dark"] .founder-title {
    color: #ffcc80;
    /* Lighter orange for dark mode */
}

.guide-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* PC: Grid Layout for Guide Items */
@media (min-width: 769px) {
    .guide-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px 20px;
    }

    .guide-item {
        flex: 1 1 30%;
        min-width: 220px;
    }
}

.guide-item {
    display: flex;
    align-items: center;
    /* keep vertical center align */
    gap: 10px;
    font-size: 0.95rem;
}

.guide-link {
    color: var(--text-main);
    /* Use variable instead of #333 */
    text-decoration: none;
    border-bottom: 1px dashed var(--text-muted);
    transition: all 0.2s;
}

[data-theme="dark"] .guide-link {
    color: #90caf9;
    /* Light blue for dark mode */
    border-bottom-color: #90caf9;
}

.guide-link:hover {
    color: #1565C0;
    border-bottom-style: solid;
}

.image-modal {
    display: none;
    position: fixed;
    z-index: 10050;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
}

.image-modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    animation: zoom 0.3s;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.image-modal-close:hover {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

@keyframes zoom {
    from {
        transform: scale(0)
    }

    to {
        transform: scale(1)
    }
}

/* ============================ */
/* 6. Help Center (QA & FAQ) */
/* ============================ */
.qa-section {
    scroll-margin-top: calc(var(--header-height) + 20px);
    margin-bottom: 40px;
}

/* Base Card Style */
.qa-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 15px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
    transition: all 0.3s;
}

.qa-card[open] {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--c-brand-blue);
}

/* Founder Theme Override */
.qa-card.founder-theme {
    background: linear-gradient(to right, #fff8e1, #ffffff);
    border-color: #ffe0b2;
}

.qa-card.founder-theme[open] {
    border-color: #FF9800;
}

[data-theme='dark'] .qa-card.founder-theme {
    background: rgba(255, 152, 0, 0.1);
    border-color: #5d4037;
}

/* Summary Styling (The Question) */
summary {
    font-weight: bold;
    font-size: 1.05rem;
    color: var(--text-main);
    cursor: pointer;
    list-style: none;
    /* Hide default triangle */
    position: relative;
    padding-right: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

summary::-webkit-details-marker {
    display: none;
}

summary::after {
    content: '\f078';
    /* fa-chevron-down */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0;
    color: var(--text-muted);
    transition: transform 0.2s;
}

details[open] summary::after {
    transform: rotate(180deg);
    color: var(--c-brand-blue);
}

.qa-card.founder-theme details[open] summary::after {
    color: #FF9800;
}

/* Content Styling (The Answer) */
.qa-content {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
    color: var(--text-secondary);
    line-height: 1.7;
}

.qa-content ol,
.qa-content ul {
    padding-left: 20px;
    margin: 10px 0;
}

/* Section Headers */
.section-header {
    color: var(--c-brand-blue);
    border-bottom: 2px solid var(--bg-body);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* TOC Styling */
.toc-box {
    position: sticky;
    top: calc(var(--header-height) + 20px);
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.toc-link {
    display: block;
    padding: 8px 0;
    color: var(--text-secondary);
    text-decoration: none;
    transition: 0.2s;
    border-left: 3px solid transparent;
    padding-left: 10px;
}

.toc-link:hover,
.toc-link.active {
    color: var(--c-brand-blue);
    border-left-color: var(--c-brand-blue);
    background: var(--bg-hover);
}

/* Legacy Sub-styles */
.qa-sub-title {
    margin: 15px 0 5px;
    font-size: 1rem;
    color: var(--text-main);
}

.brand-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    color: white;
    font-weight: bold;
}

.brand-samsung {
    background-color: #1428a0;
}

.brand-xiaomi {
    background-color: #ff6900;
}

.brand-oppo {
    background-color: #009b72;
}

@media (max-width: 768px) {
    .toc-box {
        position: static;
        margin-bottom: 20px;
    }
}