/* =========================================================
   Tutorial Studio
   Responsive Sidebar

   Desktop:
   Vertical Activity Bar + Panel

   Mobile:
   Horizontal Activity Bar + Panel
   ========================================================= */


/* =========================================================
   1. Sidebar Variables
   ========================================================= */

.sidebar {

    --activity-width: 48px;
    --sidebar-panel-width: 260px;

    --sidebar-bg: #ffffff;
    --sidebar-activity-bg: #f8fafc;

    --sidebar-border: #e5e7eb;

    --sidebar-text: #334155;
    --sidebar-muted: #64748b;

    --sidebar-primary: #2563eb;
    --sidebar-active-bg: #eef3ff;

}


/* =========================================================
   2. Desktop Sidebar
   ========================================================= */

.sidebar {

    display: flex;
    flex-direction: row;

    flex-shrink: 0;

    width: calc(
        var(--activity-width) +
        var(--sidebar-panel-width)
    );

    min-width: 0;

    height: 100%;
    min-height: 0;

    overflow: hidden;

    background: var(--sidebar-bg);

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

}


/* =========================================================
   3. Activity Bar
   ========================================================= */

.sidebar-activity-bar {

    display: flex;
    flex-direction: column;

    align-items: center;

    flex-shrink: 0;

    width: var(--activity-width);
    min-width: var(--activity-width);

    height: 100%;

    padding: 8px 4px;

    gap: 6px;

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

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

}


/* =========================================================
   4. Activity Button
   ========================================================= */

.sidebar-activity {

    position: relative;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    width: 40px;
    height: 40px;

    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: auto;
    right: -4px;
    top: 8px;
    bottom: 8px;

    width: 3px;

    border-radius: 3px 0 0 3px;

    background: var(--sidebar-primary);

}


/* =========================================================
   5. Activity Icon
   ========================================================= */

.activity-icon {

    display: block;

    font-size: 21px;
    font-weight: 600;

    line-height: 1;

    user-select: none;

}


/* Desktop 隐藏文字 */

.activity-label {

    display: none;

}


/* =========================================================
   6. Spacer
   ========================================================= */

.sidebar-activity-spacer {

    flex: 1;

}


/* =========================================================
   7. Panel Container
   ========================================================= */

.sidebar-panel-container {

    flex: 1;

    min-width: 0;
    min-height: 0;

    height: 100%;

    overflow: hidden;

    background: #ffffff;

}


/* =========================================================
   8. 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;

}


/* =========================================================
   9. 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: #111827;

    font-size: 13px;
    font-weight: 600;

}


/* =========================================================
   10. Panel Body
   ========================================================= */

.sidebar-panel-body {

    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 14px;

    overscroll-behavior: contain;

}


.sidebar-panel-body::-webkit-scrollbar {

    width: 6px;

}


.sidebar-panel-body::-webkit-scrollbar-thumb {

    background: #cbd5e1;

    border-radius: 6px;

}


/* =========================================================
   11. Page List
   ========================================================= */

.sidebar-panel .page-list {

    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 12px;

}


/* =========================================================
   12. Add Page
   ========================================================= */

.sidebar-panel .add-page {

    flex-shrink: 0;

    margin: 12px;

    padding: 11px;

    border: 1px dashed #cbd5e1;

    border-radius: 8px;

    background: #f8fafc;

    color: #334155;

    font-size: 13px;

    cursor: pointer;

}


.sidebar-panel .add-page:hover {

    border-color: #2563eb;

    background: #eff6ff;

    color: #2563eb;

}


/* =========================================================
   13. 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;

}


/* =========================================================
   14. Categories
   ========================================================= */

.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;

}


/* =========================================================
   15. Resource List
   ========================================================= */

.sidebar-resource-list {

    display: grid;

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

    gap: 10px;

}

.sidebar-panel[data-panel="audio"] .sidebar-resource-list {
    grid-template-columns: minmax(0, 1fr);
}


/* =========================================================
   16. Empty State
   ========================================================= */

.sidebar-empty {

    grid-column: 1 / -1;

    padding: 30px 10px;

    text-align: center;

    color: #94a3b8;

    font-size: 12px;

    line-height: 1.7;

}


/* =========================================================
   17. Section Title
   ========================================================= */

.sidebar-section-title {

    margin: 16px 0 12px;

    font-size: 12px;
    font-weight: 600;

    color: #475569;

}


/* =========================================================
   18. 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;

}


/* =========================================================
   19. 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;

}


/* =========================================================
   20. 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;

}


/* =========================================================
   21. 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;

}


/* =========================================================
   22. Focus
   ========================================================= */

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

    outline: 2px solid #2563eb;

    outline-offset: 2px;

}


/* =========================================================
   23. Desktop Collapsed
   ========================================================= */

.sidebar.sidebar-collapsed {

    width: var(--activity-width);

}


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

    display: none;

}


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

    border-right: none;

}


/* =========================================================
   24. Mobile
   ========================================================= */

@media (max-width: 768px) {

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

    .sidebar {

        display: flex;

        flex-direction: column;

        flex-shrink: 0;

        width: 100%;
        min-width: 0;

        height: auto;
        min-height: 0;

        max-height: none;

        overflow: hidden;

        border-right: none;

        border-top: 1px solid #e5e7eb;

        background: #ffffff;

    }


    /* ------------------------------------------
       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;

    }


    /* ------------------------------------------
       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;

        gap: 12px;

        min-height: 0;

        max-height: 175px;

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

        padding: 12px;

        scrollbar-width: thin;

        -webkit-overflow-scrolling: touch;

    }


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

    .sidebar-panel .page-list > * {

        flex-shrink: 0;

    }


    /* ------------------------------------------
       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-activity-bar {

        display: flex;

        border-bottom: none;

    }


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

        display: none;

    }

}


/* =========================================================
   25. 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;

    }

}