/**
 * 电子书样式：卡片栅格、单页信息区与积分价格标记。复用主题 CSS 变量。
 */

.ebook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 20px;
    background-color: var(--tb--white);
    border-radius: 6px;
    margin-bottom: 20px;
}

.ebook-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: var(--tb--white);
    border: 1px solid var(--tb--line);
    border-radius: 6px;
    overflow: hidden;
    transition:
        border-color 0.25s,
        box-shadow 0.25s;
}

.ebook-card:hover {
    border-color: var(--tb--main);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

.ebook-card__cover {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 7;
    overflow: hidden;
    background-color: var(--tb--tint);
}

.ebook-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
}

.ebook-card__cover--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 12px;
    text-align: center;
    font-size: 14px;
    color: var(--tb--gray);
    background-color: var(--tb--bdbg);
    word-break: break-word;
}

.ebook-card__title {
    font-size: 15px;
    line-height: 1.5;
    margin: 12px 14px 6px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.ebook-card__title a:hover {
    color: var(--tb--main);
}

.ebook-card__meta {
    margin: 0 14px;
    font-size: 12px;
    color: var(--tb--gray);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ebook-card__price {
    margin: 8px 14px;
    font-size: 14px;
    font-weight: bold;
}

.ebook-price {
    color: #ff5e52;
}

.ebook-price.is-free {
    color: #41c282;
}

.ebook-card__action {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin: auto 14px 14px;
}

.ebook-related {
    margin-bottom: 30px;
}

.ebook-related__title {
    font-size: 16px;
    margin-bottom: 12px;
}

.ebook-related .ebook-grid {
    padding: 0;
    background-color: transparent;
}

/* 单页 */

.ebook-single {
    display: flex;
    gap: 30px;
    background-color: var(--tb--white);
    border-radius: 6px;
    padding: 30px;
    margin-bottom: 30px;
}

.ebook-single__cover {
    flex: 0 0 240px;
    width: 240px;
    aspect-ratio: 5 / 7;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 6px;
    background-color: var(--tb--tint);
}

.ebook-single__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
}

.ebook-single__info {
    flex: 1;
    min-width: 0;
}

.ebook-single__title {
    font-size: 24px;
    margin-bottom: 15px;
}

.ebook-single__meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 15px;
    font-size: 14px;
    color: var(--tb--base);
    margin-bottom: 15px;
}

.ebook-single__meta dt {
    color: var(--tb--gray);
}

.ebook-single__meta dd {
    margin: 0;
}

.ebook-single__price {
    font-size: 16px;
    margin-bottom: 15px;
}

.ebook-single__action {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.ebook-single__tip {
    margin: 0;
    color: var(--tb--gray);
}

.ebook-download-code {
    font-size: 13px;
    color: var(--tb--gray);
}

/* 单页多下载链接列表 */

.ebook-downloads {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.ebook-downloads__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--tb--line);
    border-radius: 6px;
}

.ebook-download-desc {
    font-size: 12px;
    color: var(--tb--gray);
}

.ebook-shop__balance {
    margin-top: 7px;
    color: var(--tb--gray);
}

/* 书籍商城：左分类菜单 + 右卡片栅格 */

.ebook-shop {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.ebook-shop__sidebar {
    flex: 0 0 200px;
    width: 200px;
    background-color: #2f3237;
    border-radius: 6px;
    overflow: hidden;
    position: sticky;
    top: 20px;
}

.ebook-shop__cats-root,
.ebook-shop__cats-sub {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ebook-shop__cat-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: #c8cbd0;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition:
        background-color 0.2s,
        color 0.2s;
}

.ebook-shop__cat-link:hover {
    background-color: #3a3e44;
    color: #fff;
}

.ebook-shop__cat-icon {
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    opacity: 0.6;
}

.ebook-shop__cat-item.has-children > .ebook-shop__cat-link::after {
    content: "";
    margin-left: auto;
    border: solid #8a8f98;
    border-width: 0 1px 1px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(-45deg);
    transition: transform 0.2s;
}

.ebook-shop__cat-item.has-children:hover > .ebook-shop__cat-link::after {
    transform: rotate(45deg);
}

.ebook-shop__cats-sub {
    background-color: #27292d;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.ebook-shop__cat-item.has-children:hover > .ebook-shop__cats-sub,
.ebook-shop__cat-item.has-children:focus-within > .ebook-shop__cats-sub {
    max-height: 600px;
}

.ebook-shop__cats-sub .ebook-shop__cat-link {
    padding: 10px 16px 10px 42px;
    font-size: 13px;
    color: #aab0b8;
}

.ebook-shop__main {
    flex: 1;
    min-width: 0;
}

.ebook-shop__main .ebook-grid {
    padding: 0;
    background-color: transparent;
}

.ebook-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--tb--gray);
}

@media (max-width: 768px) {
    .ebook-shop {
        flex-direction: column;
    }

    .ebook-shop__sidebar {
        flex: none;
        width: 100%;
        position: static;
    }

    .ebook-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
        padding: 15px;
    }

    .ebook-single {
        flex-direction: column;
        gap: 20px;
        padding: 15px;
        border-radius: 0;
    }

    .ebook-single__cover {
        flex: none;
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }

    .ebook-single__title {
        font-size: 20px;
    }
}

/* ========== 下载弹框 ========== */

.ebook-dl-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ebook-dl-modal[hidden] {
    display: none;
}

.ebook-dl-modal__mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.ebook-dl-modal__dialog {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
}

.ebook-dl-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #eef2f7;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.ebook-dl-modal__close {
    border: none;
    background: none;
    font-size: 22px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 8px;
}

.ebook-dl-modal__close:hover {
    color: #334155;
}

.ebook-dl-modal__table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.ebook-dl-modal__table th,
.ebook-dl-modal__table td {
    padding: 12px 20px;
    border: none !important;
    border-bottom: 1px solid #eef2f7 !important;
    text-align: left;
    font-size: 14px;
    vertical-align: middle;
}

.ebook-dl-modal__table thead th {
    font-weight: 600;
    color: #64748b;
    background: #f8fafc;
}

.ebook-dl-modal__code {
    font-family: SFMono-Regular, Menlo, Consolas, monospace;
    color: #334155;
}

.ebook-dl-modal__btn {
    display: inline-block;
    padding: 6px 18px;
    border: none;
    border-radius: 4px;
    background: #d4380d;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.ebook-dl-modal__btn:hover {
    opacity: 0.88;
}

.ebook-dl-modal__notice {
    margin: 20px;
    padding: 16px 20px;
    background: #f6ffed;
    border: 1px dashed #b7eb8f;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.8;
    color: #334155;
}

.ebook-dl-modal__notice p {
    margin: 0 0 8px;
}

.ebook-dl-modal__notice ul {
    margin: 0;
    padding-left: 18px;
    list-style: disc;
}

.ebook-dl-modal__notice li {
    margin-bottom: 6px;
}

.ebook-dl-modal__notice li:last-child {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .ebook-dl-modal {
        padding: 12px;
    }

    .ebook-dl-modal__table th,
    .ebook-dl-modal__table td {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* ========== 付费 / 权限提示框 ========== */

.ebook-paywall {
    margin: 20px 0;
    padding: 30px 24px;
    background: var(--tb--tint);
    border: 1px dashed var(--tb--line);
    border-radius: 6px;
    text-align: center;
}

.ebook-paywall__title {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--tb--base);
}

.ebook-paywall__desc {
    margin: 0 0 16px;
    font-size: 14px;
    color: var(--tb--gray);
}

.ebook-paywall__action {
    margin-top: 4px;
}
