/* 手机APP风格 - 首页 */

/* 覆盖base.css */
body.homepage {
    background: linear-gradient(180deg, #1a0a2e 0%, #0d0618 100%) !important;
    color: #fff;
}

.homepage {
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(180deg, #1a0a2e 0%, #0d0618 100%);
    padding: 0 0 90px 0;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

.homepage::before {
    content: '';
    position: fixed;
    top: -30%;
    left: -30%;
    width: 160%;
    height: 80%;
    background: radial-gradient(ellipse, rgba(139, 92, 246, 0.2) 0%, transparent 70%);
    pointer-events: none;
}

/* 搜索栏 - 覆盖base.css的header */
.homepage .search-header,
.homepage header.search-header {
    background: transparent !important;
    padding: 50px 20px 30px !important;
    margin: 0 !important;
    box-shadow: none !important;
    display: block !important;
    position: relative;
    z-index: 1;
}

.homepage .search-header #search-form,
.homepage #search-form {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    height: 50px;
    background: rgba(255,255,255,0.95);
    border-radius: 25px;
    padding: 5px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    max-width: 100%;
    gap: 0;
}

.homepage .search-header #keyword,
.homepage #keyword {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 16px;
    border: none !important;
    background: transparent !important;
    font-size: 15px;
    color: #222;
    -webkit-appearance: none;
    border-radius: 20px;
}

.homepage .search-header #keyword::placeholder,
.homepage #keyword::placeholder {
    color: #888;
}

.homepage .search-header #keyword:focus,
.homepage #keyword:focus {
    outline: none;
}

.homepage .search-header button[type="submit"],
.homepage button[type="submit"] {
    flex-shrink: 0;
    height: 40px;
    padding: 0 20px;
    background: linear-gradient(90deg, #f97316, #ec4899) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 20px !important;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    -webkit-appearance: none;
}

.homepage .search-header button[type="submit"]:active,
.homepage button[type="submit"]:active {
    opacity: 0.9;
}

/* 书架 */
.bookshelf-section {
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

.bookshelf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.bookshelf-title {
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 3px;
}

.cache-manage-btn {
    padding: 6px 16px;
    background: linear-gradient(90deg, #8b5cf6, #6366f1);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.cache-manage-btn:active {
    transform: scale(0.95);
    opacity: 0.9;
}

.bookshelf-books {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.bookshelf-books.empty {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.bookshelf-book-card {
    cursor: pointer;
}

.bookshelf-book-card:active {
    transform: scale(0.95);
}

.bookshelf-book-image {
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255,255,255,0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    position: relative;
}

.bookshelf-book-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 书架封面悬浮信息 */
.bookshelf-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    padding: 20px 6px 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bookshelf-interface {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
    background: linear-gradient(90deg, #8b5cf6, #6366f1);
    color: #fff;
    align-self: flex-start;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 接口颜色区分 */
.bookshelf-interface.lam,
.bookshelf-interface.lam_api {
    background: linear-gradient(90deg, #f97316, #ea580c);
}

.bookshelf-interface.tt,
.bookshelf-interface.tt_api {
    background: linear-gradient(90deg, #06b6d4, #0891b2);
}

.bookshelf-anchor {
    font-size: 10px;
    color: rgba(255,255,255,0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* 缓存状态标签 */
.cache-status-tag {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    z-index: 10;
}

.cache-status-tag.cached {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.cache-status-tag.not-cached {
    background: linear-gradient(90deg, #6b7280, #4b5563);
}

.bookshelf-book-name {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    text-align: center;
    margin-top: 8px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.no-bookshelf {
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 14px;
    padding: 20px;
}

.loading {
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    padding: 20px;
}

/* 删除弹窗 */
.delete-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.delete-dialog {
    width: 100%;
    background: #1e1030;
    border-radius: 20px;
    padding: 24px 20px;
    text-align: center;
    margin-bottom: 20px;
}

.delete-dialog-title {
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
}

.delete-dialog-content {
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 24px;
}

.delete-dialog-buttons {
    display: flex;
    gap: 12px;
}

.delete-btn-cancel,
.delete-btn-confirm {
    flex: 1;
    height: 48px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
}

.delete-btn-cancel {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
}

.delete-btn-confirm {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    color: #fff;
}

/* Toast */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    min-width: 280px;
    max-width: 90%;
    background: rgba(20,10,35,0.98);
    color: #fff;
    padding: 16px 24px;
    border-radius: 16px;
    font-size: 15px;
    text-align: center;
    z-index: 10001;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Toast 类型样式 */
.toast.warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    border-left: 4px solid #d68910;
}

.toast.error {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border-left: 4px solid #a93226;
}

.toast.success {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    border-left: 4px solid #1e8449;
}

.toast.info {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    border-left: 4px solid #21618c;
}

/* 缓存管理弹窗 */
.cache-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.cache-modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    background: #1e1030;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cache-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.cache-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.cache-modal-close {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: rgba(255,255,255,0.6);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s;
}

.cache-modal-close:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.cache-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cache-limit-warning {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(245, 158, 11, 0.15);
    border-left: 3px solid #f59e0b;
    border-radius: 8px;
    margin-bottom: 20px;
}

.warning-icon {
    width: 20px;
    height: 20px;
    fill: #f59e0b;
    flex-shrink: 0;
}

.cache-limit-warning span {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    line-height: 1.4;
}

.cache-book-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cache-book-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    transition: all 0.3s;
}

.cache-book-item.selected {
    background: rgba(139, 92, 246, 0.2);
    border: 2px solid #8b5cf6;
}

.cache-book-item.cached {
    opacity: 0.5;
}

.cache-book-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.cache-book-checkbox input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.cache-book-checkbox input[type="checkbox"]:checked + .checkbox-custom {
    background: linear-gradient(90deg, #8b5cf6, #6366f1);
    border-color: #8b5cf6;
}

.cache-book-checkbox input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}

.cache-book-checkbox input[type="checkbox"]:disabled + .checkbox-custom {
    opacity: 0.3;
    cursor: not-allowed;
}

.cache-book-item img {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.cache-book-info {
    flex: 1;
    min-width: 0;
}

.cache-book-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cache-book-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cache-book-interface {
    font-size: 10px;
    padding: 2px 6px;
    background: linear-gradient(90deg, #8b5cf6, #6366f1);
    color: #fff;
    border-radius: 3px;
    text-transform: uppercase;
}

.cache-book-status {
    font-size: 11px;
    padding: 2px 8px;
    background: rgba(107, 114, 128, 0.3);
    color: rgba(255,255,255,0.6);
    border-radius: 10px;
}

.cache-book-status.cached {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.cache-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.cache-selected-info {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
}

.cache-selected-info span {
    font-weight: 600;
    color: #8b5cf6;
}

.cache-start-btn {
    padding: 10px 24px;
    background: linear-gradient(90deg, #8b5cf6, #6366f1);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.cache-start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cache-start-btn:not(:disabled):active {
    transform: scale(0.95);
}

/* 缓存进度弹窗 */
.cache-progress-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
}

.cache-progress-content {
    width: 100%;
    max-width: 400px;
    background: #1e1030;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
}

.cache-progress-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin: 0 0 20px 0;
}

.cache-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.cache-progress-text {
    font-size: 14px;
    color: rgba(255,255,255,0.8);
}

.cache-progress-text span {
    font-weight: 600;
    color: #8b5cf6;
}

.cache-progress-count {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
}

.cache-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.cache-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6, #6366f1);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.cache-progress-status {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    line-height: 1.5;
}

/* 小屏适配 */
@media (max-width: 360px) {
    .bookshelf-books {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .homepage .search-header,
    .homepage header.search-header {
        padding: 45px 16px 24px !important;
    }
    
    .homepage .search-header button[type="submit"],
    .homepage button[type="submit"] {
        padding: 0 16px;
        font-size: 13px;
    }
    
    .cache-modal-content {
        max-width: 100%;
    }
    
    .cache-book-item img {
        width: 50px;
        height: 67px;
    }
}
