/* =========================================================
   Tutorial Studio
   Workspace + Responsive Sidebar

   Desktop:
   Activity Bar + Sidebar Panel + Stage + Inspector

   Mobile:
   Stage
   Horizontal Activity Bar
   Sidebar Panel
   Inspector
   ========================================================= */


/* =========================================================
   1. Workspace
   ========================================================= */

.workspace {
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    min-width: 0;

    display: grid;
    grid-template-columns: 308px minmax(0, 1fr) 400px;

    overflow: hidden;
    overscroll-behavior: none;
}


/* =========================================================
   2. Sidebar Variables
   ========================================================= */

.sidebar {

    --activity-width: 48px;

    --sidebar-panel-width: 260px;

    --sidebar-bg: #ffffff;

    --sidebar-activity-bg: #f8fafc;

    --sidebar-border: #e5e7eb;

    --sidebar-primary: #2563eb;

    --sidebar-active-bg: #eef3ff;

    --sidebar-text: #334155;

    --sidebar-muted: #64748b;

}


/* =========================================================
   3. Sidebar + Inspector
   ========================================================= */

.sidebar,
.inspector {

    background: #ffffff;

    min-height: 0;

    min-width: 0;

}


/* =========================================================
   4. Sidebar
   ========================================================= */

.sidebar {

    display: flex;

    flex-direction: row;

    width: 100%;

    height: 100%;

    min-height: 0;

    min-width: 0;

    padding: 0;

    overflow: hidden;

    border-right: 1px solid var(--sidebar-border);

}


/* =========================================================
   5. Activity Bar
   ========================================================= */

.sidebar-activity-bar {
    display: flex;
    flex-direction: column;
    align-items: center;

    flex: 0 0 var(--activity-width);
    width: var(--activity-width);
    min-width: var(--activity-width);
    min-height: 0;
    height: 100%;

    box-sizing: border-box;
    padding: 10px 0;
    gap: 6px;

    background: var(--sidebar-activity-bg);
    border-right: 1px solid var(--sidebar-border);

    overflow-x: hidden;
    overflow-y: auto;

    overscroll-behavior-y: contain;
    scrollbar-width: none;
}

.sidebar-activity-bar::-webkit-scrollbar {
    display: none;
}


/* =========================================================
   6. Activity Button
   ========================================================= */

.sidebar-activity {

    position: relative;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    flex-shrink: 0;

    width: 40px;

    height: 42px;

    padding: 0;

    border: none;

    border-radius: 8px;

    background: transparent;

    color: var(--sidebar-muted);

    cursor: pointer;

    transition:
        background 0.15s ease,
        color 0.15s ease;

}


.sidebar-activity:hover {

    background: #e9eef5;

    color: #111827;

}


.sidebar-activity.active {

    background: var(--sidebar-active-bg);

    color: var(--sidebar-primary);

}


.sidebar-activity.active::before {

    content: "";

    position: absolute;

    left: -4px;

    top: 8px;

    bottom: 8px;

    width: 3px;

    border-radius: 3px;

    background: var(--sidebar-primary);

}


/* =========================================================
   7. Activity Icon
   ========================================================= */

.activity-icon {

    display: block;

    font-size: 21px;

    font-weight: 600;

    line-height: 1;

    user-select: none;

}


/* Desktop 隐藏文字 */

.activity-label {

    display: none;

}


/* =========================================================
   8. Activity Spacer
   ========================================================= */

.sidebar-activity-spacer {

    flex: 1;

}


/* =========================================================
   9. Panel Container
   ========================================================= */

.sidebar-panel-container {

    flex: 1;

    min-width: 0;

    min-height: 0;

    height: 100%;

    overflow: hidden;

    background: #ffffff;

}


/* =========================================================
   10. Sidebar Panel
   ========================================================= */

.sidebar-panel {

    display: none;

    flex-direction: column;

    width: 100%;

    height: 100%;

    min-height: 0;

    overflow: hidden;

}


.sidebar-panel.active {

    display: flex;

}


.sidebar-panel[hidden] {

    display: none !important;

}


/* =========================================================
   11. Panel Header
   ========================================================= */

.sidebar-panel .panel-head {

    display: flex;

    align-items: center;

    justify-content: space-between;

    flex-shrink: 0;

    min-height: 48px;

    padding: 0 16px;

    border-bottom: 1px solid var(--sidebar-border);

    color: #667186;

    font-size: 12px;

    font-weight: 700;

}


.sidebar-panel .panel-head span:last-child {

    background: #f0f2f6;

    padding: 2px 7px;

    border-radius: 8px;

    color: #8791a1;

}


/* =========================================================
   12. Page List
   ========================================================= */

.sidebar-panel .page-list {

    display: flex;

    flex-direction: column;

    flex: 1;

    min-height: 0;

    gap: 9px;

    padding: 12px;

    overflow-y: auto;

    overflow-x: hidden;

}


/* =========================================================
   13. Page Item
   ========================================================= */

.page-item {

    border: 1px solid var(--line);

    border-radius: 10px;

    padding: 10px;

    background: #ffffff;

    cursor: pointer;

}


.page-item.active {

    border-color: #b9c1ff;

    box-shadow: 0 0 0 2px #eef0ff;

}


/* =========================================================
   14. Thumbnail
   ========================================================= */

.thumb {

    height: 92px;

    border-radius: 7px;

    overflow: hidden;

    border: 1px solid #edf0f4;

    background: #f6f7fa;

    margin-bottom: 8px;

}


.thumb iframe {

    width: 1280px;

    height: 720px;

    transform: scale(.14);

    transform-origin: top left;

    border: 0;

    pointer-events: none;

}


/* =========================================================
   15. Page Info
   ========================================================= */

.page-name {

    font-size: 11px;

    font-weight: 700;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;

    margin-top: 3px;

}


/* =========================================================
   16. Add Page
   ========================================================= */

.sidebar-panel .add-page {

    flex-shrink: 0;

    margin: 12px;

    padding: 10px;

    border: 1px dashed #cfd5df;

    border-radius: 9px;

    background: #fafbfc;

    color: #697486;

    cursor: pointer;

}


.sidebar-panel .add-page:hover {

    border-color: #2563eb;

    background: #eff6ff;

    color: #2563eb;

}


/* =========================================================
   17. Panel Body
   ========================================================= */

.sidebar-panel-body {

    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 14px;

    overscroll-behavior: contain;

}


/* =========================================================
   18. Search
   ========================================================= */

.sidebar-search {

    box-sizing: border-box;

    width: 100%;

    height: 36px;

    padding: 0 12px;

    border: 1px solid #dce2ea;

    border-radius: 7px;

    outline: none;

    background: #ffffff;

    color: #111827;

    font-size: 12px;

}


.sidebar-search:focus {

    border-color: #2563eb;

}


/* =========================================================
   19. Category
   ========================================================= */

.sidebar-category-list {

    display: flex;

    flex-wrap: wrap;

    gap: 7px;

    margin: 14px 0 16px;

}


.sidebar-category {

    padding: 7px 10px;

    border: 1px solid #e5e7eb;

    border-radius: 6px;

    background: #ffffff;

    color: #475569;

    font-size: 12px;

    cursor: pointer;

}


.sidebar-category:hover {

    background: #f1f5f9;

}


.sidebar-category.active {

    color: #2563eb;

    background: #eff6ff;

    border-color: #bfdbfe;

}


/* =========================================================
   20. Resource List
   ========================================================= */

.sidebar-resource-list {

    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 10px;

}


/* =========================================================
   21. Empty State
   ========================================================= */

.sidebar-empty {

    grid-column: 1 / -1;

    padding: 30px 10px;

    text-align: center;

    color: #94a3b8;

    font-size: 12px;

    line-height: 1.7;

}


/* =========================================================
   22. Section Title
   ========================================================= */

.sidebar-section-title {

    margin: 16px 0 12px;

    font-size: 12px;

    font-weight: 600;

    color: #475569;

}


/* =========================================================
   23. Primary Button
   ========================================================= */

.sidebar-primary-btn {

    width: 100%;

    min-height: 36px;

    padding: 8px 12px;

    border: none;

    border-radius: 7px;

    background: #2563eb;

    color: #ffffff;

    font-size: 12px;

    font-weight: 500;

    cursor: pointer;

}


.sidebar-primary-btn:hover {

    background: #1d4ed8;

}


.sidebar-audio-hint {
    margin: 8px 0 16px;
    color: #64748b;
    font-size: 11px;
    line-height: 1.6;
}

.sidebar-audio-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

.sidebar-audio-item {
    min-width: 0;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
}

.sidebar-audio-item-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin-bottom: 10px;
}

.sidebar-audio-item-head strong {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: #334155;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-audio-item-head button {
    flex: 0 0 auto;
    padding: 2px 6px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
}

.sidebar-audio-item-head button:hover {
    background: #fef2f2;
    color: #dc2626;
}

.sidebar-audio-trim {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.sidebar-audio-section-title {
    grid-column: 1 / -1;
    margin: 3px 0 -3px;
    color: #475569;
    font-size: 10px;
    font-weight: 650;
}

.sidebar-audio-trim label {
    display: grid;
    gap: 4px;
    color: #64748b;
    font-size: 10px;
}

.sidebar-audio-trim input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: 30px;
    padding: 0 7px;
    border: 1px solid #dbe2ea;
    border-radius: 5px;
    color: #334155;
    font-size: 11px;
}

.sidebar-audio-trim input:focus {
    border-color: #818cf8;
    outline: 2px solid #6366f11a;
}

.sidebar-audio-duration {
    margin: 8px 0 0;
    color: #94a3b8;
    font-size: 10px;
}

.sidebar-audio-trim-note {
    margin: 7px 0 0;
    color: #64748b;
    font-size: 10px;
    line-height: 1.5;
}

.sidebar-audio-editor-btn {
    width: 100%;
    min-height: 34px;
    margin-top: 16px;
    padding: 7px 8px;
    border: 1px solid #dbe2ea;
    border-radius: 7px;
    background: #f8fafc;
    color: #475569;
    font-size: 11px;
    cursor: pointer;
}

.sidebar-audio-editor-btn:hover {
    border-color: #c7d2fe;
    background: #eef2ff;
    color: #4338ca;
}


/* =========================================================
   24. Text Cards
   ========================================================= */

.sidebar-tool-card {

    display: block;

    width: 100%;

    min-height: 58px;

    margin-bottom: 10px;

    padding: 12px;

    text-align: left;

    background: #ffffff;

    border: 1px solid #e5e7eb;

    border-radius: 8px;

    cursor: pointer;

}


.sidebar-tool-card:hover {

    border-color: #93c5fd;

    background: #f8fbff;

}


.sidebar-text-heading {

    font-size: 23px;

    font-weight: 700;

}


.sidebar-text-subheading {

    font-size: 17px;

    font-weight: 600;

}


.sidebar-text-paragraph {

    font-size: 13px;

    color: #475569;

}


/* =========================================================
   25. Icon Button
   ========================================================= */

.sidebar-icon-btn {

    width: 28px;

    height: 28px;

    border: none;

    border-radius: 6px;

    background: transparent;

    color: #64748b;

    cursor: pointer;

}


.sidebar-icon-btn:hover {

    background: #f1f5f9;

}


/* =========================================================
   26. Settings
   ========================================================= */

.sidebar-setting-row {

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 12px;

    margin-bottom: 12px;

}


.sidebar-setting-row label {

    font-size: 12px;

    color: #475569;

}


.sidebar-setting-row input {

    width: 100px;

    height: 34px;

    padding: 0 8px;

    border: 1px solid #dce2ea;

    border-radius: 6px;

    background: #ffffff;

    color: #111827;

    font-size: 12px;

}


/* =========================================================
   27. Focus
   ========================================================= */

.sidebar-activity:focus-visible,
.sidebar-category:focus-visible,
.sidebar-tool-card:focus-visible {

    outline: 2px solid #2563eb;

    outline-offset: 2px;

}


/* =========================================================
   28. Desktop Collapsed

   注意：
   Sidebar 收起时，workspace 的 Grid 列宽
   也必须一起改变。
   ========================================================= */

@media (min-width: 769px) {

    .workspace:has(.sidebar.sidebar-collapsed) {

        grid-template-columns:
            48px minmax(0, 1fr) 400px;

    }

    .sidebar.sidebar-collapsed .sidebar-panel-container {

        display: none;

    }

    .sidebar.sidebar-collapsed {

        width: 100%;

    }

}


/* =========================================================
   29. Mobile Workspace

   画布 -> Sidebar -> Inspector

   假设：
   .workspace 直接包含
   .sidebar
   .stage-wrap
   .inspector
   ========================================================= */

@media (max-width: 768px) {

    .workspace {

        display: flex;

        flex-direction: column;

        width: 100%;

        min-width: 0;

        min-height: 0;

        height: auto;

        flex: none;

        overflow: visible;

    }


    /* ------------------------------------------
       Stage
       ------------------------------------------ */

    .workspace>.stage-wrap {

        order: 1;

        flex: none;

        width: 100%;

        min-width: 0;

        height: 45vh;

        min-height: 260px;

    }


    /* ------------------------------------------
       Sidebar
       ------------------------------------------ */

    .workspace>.sidebar {

        order: 2;

        flex: none;

        display: flex;

        flex-direction: column;

        width: 100%;

        min-width: 0;

        height: auto;

        min-height: 60px;

        padding: 0;

        overflow: hidden;

        border-right: none;

        border-top: 1px solid #e5e7eb;

    }


    /* ------------------------------------------
       Inspector
       ------------------------------------------ */

    .workspace>.inspector {

        order: 3;

        flex: none;

        width: 100%;

        min-width: 0;

    }


    /* ------------------------------------------
       Activity Bar
       ------------------------------------------ */

    .sidebar-activity-bar {

        display: flex;

        flex-direction: row;

        align-items: center;

        justify-content: flex-start;

        flex-shrink: 0;

        width: 100%;

        min-width: 0;

        height: 60px;

        min-height: 60px;

        box-sizing: border-box;

        padding: 0 8px;

        gap: 4px;

        overflow-x: auto;

        overflow-y: hidden;

        flex-wrap: nowrap;

        border-right: none;

        border-bottom: 1px solid #e5e7eb;

        background: #f8fafc;

        scrollbar-width: none;

        -webkit-overflow-scrolling: touch;

        overscroll-behavior-x: contain;

        touch-action: pan-x;

    }


    .sidebar-activity-bar::-webkit-scrollbar {

        display: none;

    }


    /* ------------------------------------------
       Activity Button
       ------------------------------------------ */

    .sidebar-activity {

        display: flex;

        flex-direction: column;

        align-items: center;

        justify-content: center;

        flex: 0 0 52px;

        width: 52px;

        min-width: 52px;

        height: 52px;

        padding: 4px 0;

        gap: 5px;

        border-radius: 8px;

    }


    /* ------------------------------------------
       Icon
       ------------------------------------------ */

    .activity-icon {

        font-size: 20px;

        line-height: 1;

    }


    /* ------------------------------------------
       Label
       ------------------------------------------ */

    .activity-label {

        display: block;

        font-size: 10px;

        font-weight: 500;

        line-height: 1;

        white-space: nowrap;

    }


    /* ------------------------------------------
       Active
       ------------------------------------------ */

    .sidebar-activity.active {

        background: #eef3ff;

        color: #2563eb;

    }


    .sidebar-activity.active::before {

        left: 10px;

        right: 10px;

        top: auto;

        bottom: 0;

        width: auto;

        height: 3px;

        border-radius: 3px 3px 0 0;

    }


    /* ------------------------------------------
       Spacer
       ------------------------------------------ */

    .sidebar-activity-spacer {

        display: none;

    }


    /* ------------------------------------------
       Panel Container
       ------------------------------------------ */

    .sidebar-panel-container {

        flex: none;

        width: 100%;

        height: auto;

        min-height: 0;

        max-height: 280px;

        overflow: hidden;

    }


    /* ------------------------------------------
       Panel
       ------------------------------------------ */

    .sidebar-panel {

        width: 100%;

        height: auto;

        min-height: 0;

        max-height: 280px;

        overflow: hidden;

    }


    /* ------------------------------------------
       Panel Header
       ------------------------------------------ */

    .sidebar-panel .panel-head {

        min-height: 42px;

        padding: 0 14px;

    }


    /* ------------------------------------------
       Page List
       横向排列
       ------------------------------------------ */

    .sidebar-panel .page-list {

        display: flex;

        flex-direction: row;

        flex-wrap: nowrap;

        flex: none;

        gap: 12px;

        min-height: 0;

        max-height: 175px;

        padding: 12px;

        overflow-x: auto;

        overflow-y: hidden;

        scrollbar-width: thin;

        -webkit-overflow-scrolling: touch;

    }


    /* ------------------------------------------
       Page Item
       ------------------------------------------ */

    .sidebar-panel .page-item {

        flex: 0 0 150px;

        width: 150px;

        box-sizing: border-box;

    }


    /* ------------------------------------------
       Thumbnail
       ------------------------------------------ */

    .sidebar-panel .thumb {

        height: 85px;

    }


    /* ------------------------------------------
       Add Page
       ------------------------------------------ */

    .sidebar-panel .add-page {

        margin: 8px 12px 12px;

        padding: 9px;

    }


    /* ------------------------------------------
       Panel Body
       ------------------------------------------ */

    .sidebar-panel-body {

        flex: none;

        min-height: 0;

        max-height: 220px;

        overflow-y: auto;

        padding: 12px;

        -webkit-overflow-scrolling: touch;

    }


    /* ------------------------------------------
       Collapsed
       ------------------------------------------ */

    .sidebar.sidebar-collapsed {

        width: 100%;

        height: 60px;

        min-height: 60px;

    }


    .sidebar.sidebar-collapsed .sidebar-panel-container {

        display: none;

    }


    .sidebar.sidebar-collapsed .sidebar-activity-bar {

        display: flex;

        border-bottom: none;

    }

}


/* =========================================================
   30. Small Mobile
   ========================================================= */

@media (max-width: 390px) {

    .sidebar-activity {

        flex-basis: 48px;

        width: 48px;

        min-width: 48px;

    }


    .activity-icon {

        font-size: 19px;

    }


    .activity-label {

        font-size: 10px;

    }

}

/* =========================================================
   左右栏细节统一
   ========================================================= */

.sidebar-panel .panel-head {
    font-size: 13px;
    font-weight: 650;
}

@media (min-width: 901px) {

    .sidebar-activity-bar {
        padding: 8px 4px;
        gap: 6px;
    }

    .sidebar-activity {
        flex: 0 0 40px;

        width: 40px;
        height: 40px;
    }

    /*
     * 选中竖线放在靠近内容面板的一侧，
     * 不再贴着工作区最外侧。
     */
    .sidebar-activity.active::before {
        left: auto;
        right: -4px;

        border-radius: 3px 0 0 3px;
    }
}

/* 页面面板标题与右侧标题同高 */
.sidebar-panel[data-panel="pages"] .panel-head {
    min-height: 48px;
    height: 48px;
    box-sizing: border-box;
}
