/**
 * 移动端阅读页样式 - m-reader.css
 * 用于: chapters/index.html
 */

/* ========== 基础重置 ========== */
.reader-page * { margin: 0; padding: 0; box-sizing: border-box; }
.reader-page { background: var(--bg-primary); color: var(--text-primary); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
.reader-page a { text-decoration: none; color: inherit; }

/* ========== 顶部导航（阅读页专用） ========== */
.reader-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: #ffffff !important;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

.reader-navbar__logo { height: 28px; }
.reader-navbar__actions { display: flex; align-items: center; gap: 12px; }
.reader-navbar__btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333 !important;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}
.reader-navbar__btn:active { background: #f5f5f5; }
.reader-navbar__avatar { width: 32px; height: 32px; border-radius: 50%; }

/* ========== 漫画信息区 ========== */
.book-info {
    margin-top: 0;
    padding: 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--divider);
}

.book-info__header { display: flex; gap: 12px; }
.book-info__cover { width: 80px; flex-shrink: 0; }
.book-info__cover img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 8px;
}
.book-info__detail { flex: 1; min-width: 0; }
.book-info__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}
.book-info__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}
.book-info__status {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
}
.book-info__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: calc(3 * (11px * 1.4 + 4px + 6px));
    overflow: hidden;
    line-height: 1.4;
}
.book-info__tag {
    padding: 2px 8px;
    font-size: 11px;
    background: rgba(233, 30, 99, 0.1);
    color: var(--primary);
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
}
.book-info__tag:active { background: rgba(233, 30, 99, 0.2); }
.book-info__favorite-inline {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    font-size: 12px;
    color: var(--primary);
    background: rgba(233, 30, 99, 0.1);
    border: 1px solid var(--primary);
    border-radius: 12px;
    cursor: pointer;
    margin-left: auto;
}
.book-info__favorite-inline:active { transform: scale(0.95); }
.book-info__favorite-inline.favorited { background: var(--primary); color: #fff; }
.book-info__favorite-inline.favorited svg { fill: #fff; }

/* ========== 章节选择器 ========== */
.chapter-selector {
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--divider);
}
.chapter-selector__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.chapter-selector__current {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.chapter-selector__toggle {
    padding: 6px 12px;
    font-size: 12px;
    color: var(--primary);
    background: rgba(233, 30, 99, 0.1);
    border: none;
    border-radius: 16px;
    cursor: pointer;
}
.chapter-selector__list {
    display: none;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 12px;
}
.chapter-selector__list.show { display: block; }
.chapter-selector__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.chapter-selector__item {
    padding: 8px 4px;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    border-radius: 6px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chapter-selector__item.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ========== 翻页导航 ========== */
.page-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--divider);
}
.page-nav__btn {
    flex: 1;
    max-width: 120px;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
}
.page-nav__btn.disabled { opacity: 0.4; pointer-events: none; }
.page-nav__btn--primary {
    background: linear-gradient(135deg, #e91e63 0%, #9c27b0 100%);
    border-color: transparent;
    color: #fff;
}

/* ========== 漫画内容区（全屏沉浸式） ========== */
.reader-content { padding: 0; background: #000; }
.reader-images {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}
.reader-img-wrapper {
    width: 100%;
    overflow: hidden;
    position: relative;
}
.reader-images img {
    width: 100%;
    height: auto;
    display: block;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: pan-y;
    transform-origin: center center;
    will-change: transform;
}
.reader-images img.zoomed-state { touch-action: none; }
.reader-images img.smooth-transition {
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.reader-images img.draggable { cursor: grab; }
.reader-images img.dragging { cursor: grabbing; }

/* ========== 广告提示 ========== */
.ad-notice {
    text-align: center;
    padding: 20px 16px;
    font-size: 13px;
    color: var(--text-tertiary);
}

/* ========== 底部翻页 ========== */
.bottom-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-card);
}
.bottom-nav__btn {
    flex: 1;
    max-width: 140px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
}
.bottom-nav__btn--primary {
    background: linear-gradient(135deg, #e91e63 0%, #9c27b0 100%);
    border-color: transparent;
    color: #fff;
}
.bottom-nav__btn.disabled { opacity: 0.4; pointer-events: none; }

/* ========== 评论区 ========== */
.comment-section {
    padding: 16px;
    background: var(--bg-card);
    margin-top: 8px;
}
.comment-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.comment-section__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.comment-section__btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #e91e63 0%, #9c27b0 100%);
    border: none;
    border-radius: 20px;
    cursor: pointer;
}
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment-item {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: 10px;
}
.comment-item__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}
.comment-item__body { flex: 1; min-width: 0; }
.comment-item__author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.comment-item__text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 4px;
}
.comment-item__time {
    font-size: 11px;
    color: var(--text-muted);
}
.comment-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ========== 评论输入框 ========== */
.comment-input { margin-bottom: 16px; }
.comment-input__textarea {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    border-radius: 10px;
    resize: none;
    outline: none;
    font-family: inherit;
}
.comment-input__textarea:focus { border-color: var(--primary); }
.comment-input__textarea::placeholder { color: var(--text-muted); }
.comment-input__btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #e91e63 0%, #9c27b0 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
.comment-input__btn:active { opacity: 0.9; }

/* ========== 底部安全区 ========== */
.safe-bottom { height: calc(20px + env(safe-area-inset-bottom)); }

/* ========== 评论弹窗 ========== */
.comment-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
}
.comment-modal.show { display: block; }
.comment-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}
.comment-modal__content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: 16px 16px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
.comment-modal.show .comment-modal__content { transform: translateY(0); }
.comment-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.comment-modal__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.comment-modal__close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}
.comment-modal__textarea {
    width: 100%;
    height: 120px;
    padding: 12px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    border-radius: 10px;
    resize: none;
    outline: none;
    font-family: inherit;
}
.comment-modal__textarea:focus { border-color: var(--primary); }
.comment-modal__textarea::placeholder { color: var(--text-muted); }
.comment-modal__submit {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #e91e63 0%, #9c27b0 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
.comment-modal__submit:active { opacity: 0.9; }

/* ========== 浮层工具栏 ========== */
.float-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 200;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.float-toolbar--top {
    top: 0;
    transform: translateY(-100%);
    opacity: 0;
}
.float-toolbar--bottom {
    bottom: 0;
    transform: translateY(100%);
    opacity: 0;
}
.float-toolbar.visible {
    transform: translateY(0);
    opacity: 1;
}
.float-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}
.float-header__back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.float-header__info { flex: 1; min-width: 0; margin: 0 12px; }
.float-header__title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.float-header__chapter {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* 顶栏按钮 */
.float-header__btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    margin-left: 8px;
    transition: all 0.2s ease;
}
.float-header__btn:active {
    transform: scale(0.95);
    background: rgba(255,255,255,0.2);
}
.float-header__btn.favorited {
    background: rgba(233,30,99,0.2);
    border-color: rgba(233,30,99,0.4);
}
.float-header__btn.favorited svg {
    fill: #e91e63;
    stroke: #e91e63;
}

/* 底栏容器 */
.float-footer {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.85) 100%);
    backdrop-filter: blur(12px);
    gap: 8px;
}

/* 底栏按钮 - 统一风格 */
.float-footer__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: rgba(255,255,255,0.9);
    font-size: 10px;
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    border-radius: 10px;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
}
.float-footer__item:active {
    transform: scale(0.96);
    background: rgba(255,255,255,0.15);
}
.float-footer__item.disabled {
    opacity: 0.3;
    pointer-events: none;
}
.float-footer__icon { width: 20px; height: 20px; }

/* ========== PC端响应式适配 ========== */
@media (min-width: 768px) {
    .book-info,
    .chapter-selector,
    .page-nav,
    .ad-notice,
    .reader-content,
    .bottom-nav,
    .comment-section,
    .safe-bottom {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
    }
    .reader-content { max-width: 1200px; }
    .float-header { max-width: 1200px; margin: 0 auto; }
    .float-footer { max-width: 1200px; margin: 0 auto; }
    .comment-modal__content {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        border-radius: 16px 16px 0 0;
    }
    .comment-modal.show .comment-modal__content {
        transform: translateX(-50%) translateY(0);
    }
    .chapter-selector__grid { grid-template-columns: repeat(6, 1fr); }
    .chapter-selector__list { max-height: 300px; }
}

@media (min-width: 1200px) {
    .chapter-selector__grid { grid-template-columns: repeat(8, 1fr); }
}

