/**
 * =========================================================
 * Tutorial Studio
 * Text Panel
 *
 * 文件：css/main/sidebar/text/text_panel.css
 *
 * 左侧文字样式面板：
 * 搜索、快捷分类、设计分类、样式卡片、收藏、
 * 空状态与展开更多。
 * =========================================================
 */

.text-panel {
    --text-panel-accent: #4f46e5;
    --text-panel-line: #e7ebf2;
    --text-panel-muted: #94a3b8;
}

.text-panel-body {
    padding: 12px 12px 24px;
}

.text-style-library {
    min-width: 0;
}

/* =========================================================
   01. 面板头部
========================================================= */

.text-panel-head {
    gap: 8px;
}

.text-panel-browse {
    display: inline-flex;
    align-items: center;
    gap: 5px;

    height: 26px;

    padding: 0 8px;

    border: 1px solid #dfe5ee;
    border-radius: 999px;

    background: #ffffff;

    color: #475569;

    font: inherit;
    font-size: 11px;
    font-weight: 650;

    cursor: pointer;

    transition:
        border-color .16s ease,
        background .16s ease,
        color .16s ease;
}

.text-panel-browse:hover {
    border-color: #c7d2fe;
    background: #f5f7ff;
    color: #4338ca;
}

.text-panel-browse:focus-visible {
    outline: 2px solid var(--text-panel-accent);
    outline-offset: 2px;
}

.text-panel-browse-count {
    display: inline-grid;
    place-items: center;

    min-width: 18px;
    height: 16px;

    padding: 0 4px;

    border-radius: 999px;

    background: #eef2ff;

    color: #4338ca;

    font-size: 9.5px;
    font-weight: 750;
}


/* =========================================================
   02. 搜索
========================================================= */

.text-style-search {
    position: relative;

    display: flex;
    align-items: center;

    height: 34px;

    margin-bottom: 10px;

    border: 1px solid var(--text-panel-line);
    border-radius: 10px;

    background: #f8fafc;

    transition:
        border-color .16s ease,
        background .16s ease,
        box-shadow .16s ease;
}

.text-style-search:focus-within {
    border-color: #a5b4fc;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}

.text-style-search-icon {
    position: absolute;
    left: 10px;

    color: var(--text-panel-muted);

    font-size: 14px;
    line-height: 1;

    pointer-events: none;
}

.text-style-search input {
    width: 100%;
    height: 100%;

    padding: 0 32px 0 30px;

    border: 0;

    background: transparent;

    color: #0f172a;

    font: inherit;
    font-size: 12px;

    outline: none;
}

.text-style-search input::placeholder {
    color: #9aa6b8;
}

.text-style-search input::-webkit-search-cancel-button {
    display: none;
}

.text-style-search-clear {
    position: absolute;
    right: 5px;

    display: grid;
    place-items: center;

    width: 22px;
    height: 22px;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: #e2e8f0;

    color: #475569;

    font-size: 13px;
    line-height: 1;

    cursor: pointer;
}

.text-style-search-clear[hidden] {
    display: none;
}

.text-style-search-clear:hover {
    background: #cbd5e1;
}


/* =========================================================
   03. 快捷分类
========================================================= */

.text-quick-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));

    gap: 3px;

    margin-bottom: 10px;
    padding: 3px;

    border-radius: 10px;

    background: #f1f5f9;
}

.text-quick-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;

    min-width: 0;
    height: 28px;

    padding: 0 4px;

    border: 0;
    border-radius: 8px;

    background: transparent;

    color: #64748b;

    font: inherit;
    font-size: 11.5px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background .16s ease,
        color .16s ease,
        box-shadow .16s ease;
}

.text-quick-tab:hover {
    color: #4338ca;
}

.text-quick-tab.is-active {
    background: #ffffff;

    color: #3730a3;

    box-shadow:
        0 2px 6px rgba(15, 23, 42, .08);
}

.text-quick-tab:focus-visible {
    outline: 2px solid var(--text-panel-accent);
    outline-offset: 1px;
}

.text-quick-count {
    display: inline-grid;
    place-items: center;

    min-width: 14px;
    height: 14px;

    padding: 0 3px;

    border-radius: 999px;

    background: #e0e7ff;

    color: #4338ca;

    font-size: 9px;
    font-weight: 750;
}


/* =========================================================
   04. 设计分类（横向滚动）
========================================================= */

.text-style-category-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;

    margin-bottom: 4px;

    padding: 2px 0 4px;

    overflow: visible;
}

.text-style-category-scroll::-webkit-scrollbar {
    display: none;
}

.text-style-category {

    min-height: 26px;

    padding: 4px 10px;

    border: 1px solid #e2e8f0;
    border-radius: 999px;

    background: #ffffff;

    color: #475569;

    font: inherit;
    font-size: 11px;
    line-height: 1.4;

    white-space: nowrap;

    cursor: pointer;

    transition:
        background .16s ease,
        border-color .16s ease,
        color .16s ease,
        box-shadow .16s ease;
}

.text-style-category:hover {
    border-color: #c7d2fe;
    background: #f8faff;
    color: #4338ca;
}

.text-style-category.is-active {
    border-color: transparent;

    background:
        linear-gradient(135deg, #4f46e5, #7c3aed);

    color: #ffffff;

    font-weight: 700;

    box-shadow:
        0 4px 12px rgba(79, 70, 229, .24);
}

.text-style-category:focus-visible {
    outline: 2px solid var(--text-panel-accent);
    outline-offset: 2px;
}


/* =========================================================
   05. 结果栏
========================================================= */

.text-style-results-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: 8px;

    margin: 8px 0 10px;
}

.text-style-results-copy {
    min-width: 0;
}

.text-style-results-copy h3 {
    margin: 0;

    overflow: hidden;

    color: #0f172a;

    font-size: 13px;
    font-weight: 750;
    line-height: 1.4;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.text-style-results-copy p {
    margin: 3px 0 0;

    overflow: hidden;

    color: var(--text-panel-muted);

    font-size: 10.5px;
    line-height: 1.45;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.text-style-results-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;

    gap: 5px;
}

.text-style-refresh {
    display: inline-flex;
    align-items: center;
    gap: 3px;

    height: 24px;

    padding: 0 8px;

    border: 1px solid #dfe4ee;
    border-radius: 999px;

    background: #ffffff;

    color: #475569;

    font: inherit;
    font-size: 10.5px;
    font-weight: 650;

    white-space: nowrap;

    cursor: pointer;

    transition:
        background .16s ease,
        border-color .16s ease,
        color .16s ease;
}

.text-style-refresh[hidden] {
    display: none;
}

.text-style-refresh:hover {
    border-color: #a5b4fc;
    background: #f5f7ff;
    color: #4338ca;
}

.text-style-refresh:focus-visible {
    outline: 2px solid var(--text-panel-accent);
    outline-offset: 2px;
}

.text-style-count {
    flex-shrink: 0;

    padding: 4px 8px;

    border-radius: 999px;

    background:
        linear-gradient(135deg, #eef2ff, #e0e7ff);

    color: #4338ca;

    font-size: 10px;
    font-weight: 750;

    white-space: nowrap;
}


/* =========================================================
   06. 卡片网格
========================================================= */

.text-style-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 9px;

    min-width: 0;
}

.text-style-tile {
    position: relative;

    min-width: 0;
}


/* =========================================================
   07. 样式卡片
========================================================= */

.text-style-card {
    display: flex;
    flex-direction: column;

    width: 100%;
    min-width: 0;

    gap: 6px;

    padding: 6px;

    overflow: hidden;

    border: 1px solid var(--text-panel-line);
    border-radius: 12px;

    background: #ffffff;

    text-align: left;

    cursor: pointer;

    transition:
        transform .18s ease,
        border-color .18s ease,
        box-shadow .18s ease;
}

.text-style-card:hover {
    border-color: var(--ts-text-accent, #6366f1);

    transform: translateY(-2px);

    box-shadow:
        0 10px 22px rgba(30, 41, 59, .12);
}

.text-style-card:active {
    transform: translateY(0);
}

.text-style-card:focus-visible {
    outline: 2px solid var(--ts-text-accent, #6366f1);
    outline-offset: 2px;
}

.text-style-card:disabled {
    opacity: .6;
    cursor: wait;
}

.text-style-card .ts-text-preview {
    height: 78px;

    border-radius: 8px;

    box-shadow:
        inset 0 0 0 1px rgba(15, 23, 42, .06);
}

.text-style-card-name {
    display: block;

    min-width: 0;

    padding: 0 2px 1px;

    overflow: hidden;

    color: #334155;

    font-size: 11.5px;
    font-weight: 650;
    line-height: 1.4;

    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ---------- 插入提示 ---------- */

.text-style-card-insert {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 31px;

    display: grid;
    place-items: center;

    height: 20px;

    border-radius: 0 0 8px 8px;

    background:
        linear-gradient(180deg, transparent, rgba(15, 23, 42, .62));

    color: #ffffff;

    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .02em;

    opacity: 0;

    transition: opacity .16s ease;

    pointer-events: none;
}

.text-style-card:hover .text-style-card-insert,
.text-style-card:focus-visible .text-style-card-insert {
    opacity: 1;
}


/* ---------- 收藏 ---------- */

.text-style-favorite {
    position: absolute;
    top: 10px;
    right: 10px;

    z-index: 2;

    display: grid;
    place-items: center;

    width: 22px;
    height: 22px;

    padding: 0;

    border:
        1px solid rgba(255, 255, 255, .62);

    border-radius: 50%;

    background: rgba(15, 23, 42, .46);

    color: #ffffff;

    font-size: 12px;
    line-height: 1;

    opacity: 0;

    transform: scale(.9);

    cursor: pointer;

    transition:
        opacity .16s ease,
        transform .16s ease,
        background .16s ease,
        color .16s ease;

    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.text-style-card:hover+.text-style-favorite,
.text-style-tile:hover .text-style-favorite,
.text-style-tile:focus-within .text-style-favorite,
.text-style-favorite:focus-visible,
.text-style-favorite.is-active {
    opacity: 1;

    transform: scale(1);
}

.text-style-favorite:hover {
    background: rgba(15, 23, 42, .72);
}

.text-style-favorite.is-active {
    border-color: rgba(251, 191, 36, .55);

    background: rgba(15, 23, 42, .68);

    color: #fbbf24;
}

.text-style-favorite:focus-visible {
    outline: 2px solid #fbbf24;
    outline-offset: 1px;
}


/* =========================================================
   08. 展开更多
========================================================= */

.text-style-load-more-container {
    margin-top: 12px;
}

.text-style-load-more {
    display: flex;
    width: 100%;
    min-height: 38px;
    align-items: center;
    justify-content: center;

    gap: 7px;

    padding: 8px 12px;

    border: 1px dashed #cdd5e4;
    border-radius: 10px;

    background: #ffffff;

    color: #4338ca;

    font: inherit;
    font-size: 12px;
    font-weight: 700;

    cursor: pointer;

    transition:
        background .16s ease,
        border-color .16s ease;
}

.text-style-load-more:hover {
    border-color: #a5b4fc;
    background: #f5f7ff;
}

.text-style-load-more:focus-visible {
    outline: 2px solid var(--text-panel-accent);
    outline-offset: 2px;
}

.text-style-load-more span:not(.text-style-load-more-label) {
    color: #64748b;

    font-size: 11px;
    font-weight: 500;
}


/* =========================================================
   09. 空状态
========================================================= */

.text-style-empty {
    grid-column: 1 / -1;

    padding: 28px 14px;

    border: 1px dashed #cbd5e1;
    border-radius: 12px;

    background:
        linear-gradient(135deg, #f8fafc, #f1f5f9);

    text-align: center;
}

.text-style-empty-icon {
    display: grid;
    place-items: center;

    width: 38px;
    height: 38px;

    margin: 0 auto 9px;

    border-radius: 50%;

    background: #eef2ff;

    color: #4f46e5;

    font-size: 15px;
    font-weight: 800;
}

.text-style-empty-title {
    color: #334155;

    font-size: 13px;
    font-weight: 700;
}

.text-style-empty-description {
    margin-top: 5px;

    color: #64748b;

    font-size: 11.5px;
    line-height: 1.6;
}

.text-style-empty-action {
    margin-top: 10px;

    padding: 6px 14px;

    border: 1px solid #c7d2fe;
    border-radius: 999px;

    background: #ffffff;

    color: #4338ca;

    font: inherit;
    font-size: 11px;
    font-weight: 650;

    cursor: pointer;
}

.text-style-empty-action:hover {
    background: #eef2ff;
}


/* =========================================================
   10. 响应式
========================================================= */

@media (max-width: 360px) {
    .text-panel-body {
        padding-right: 10px;
        padding-left: 10px;
    }

    .text-style-grid {
        gap: 7px;
    }

    .text-style-card {
        padding: 5px;
    }

    .text-style-card .ts-text-preview {
        height: 68px;
    }

    .text-style-card-name {
        font-size: 11px;
    }

    .text-style-category {
        padding-right: 8px;
        padding-left: 8px;

        font-size: 10.5px;
    }

    .text-style-card-insert {
        left: 5px;
        right: 5px;
        bottom: 29px;
    }

    .text-style-favorite {
        top: 8px;
        right: 8px;

        width: 20px;
        height: 20px;

        font-size: 11px;
    }
}


/* =========================================================
   11. 触屏 / 减少动态效果
========================================================= */

@media (hover: none) {
    .text-style-favorite {
        opacity: .85;

        transform: none;
    }

    .text-style-card-insert {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .text-style-card,
    .text-style-category,
    .text-style-load-more,
    .text-style-refresh,
    .text-style-favorite,
    .text-style-card-insert,
    .text-panel-browse {
        transition: none;
    }

    .text-style-card:hover {
        transform: none;
    }
}
