/* ============================================
 * 搜书神器 - 简约主题 (清新极简风格)
 * 适用于：追求简洁、快速浏览
 * 特点：白色背景、扁平设计、无渐变
 * ============================================ */

/* ========== 基础重置与全局样式 ========== */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
    background: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 0;
}

/* ========== 头部导航区域 ========== */
.header {
    background: white;
    padding: 12px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: auto;
    min-height: 80px;
    max-height: 14vh;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-shrink: 0;
}

.logo-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.header h1 {
    font-size: 18px;
    color: #333;
    text-align: center;
    margin: 0;
    font-weight: 600;
    line-height: 1.2;
}

/* ========== 聊天/消息区域 ========== */
.chat-container {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    top: calc(14vh);
    bottom: 60px;
    min-height: 0;
    z-index: 1;
    overflow: hidden;
    border-radius: 16px 16px 0 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    scroll-behavior: smooth;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    background: transparent;
}

.message {
    margin-bottom: 16px;
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    word-break: break-word;
}

.message.user .message-bubble {
    background: #333;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ========== 输入区域 ========== */
.input-area {
    background: white;
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    align-items: center;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.08);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
}

.input-area input {
    flex: 1;
    border: 1px solid #e0e0e0;
    outline: none;
    font-size: 15px;
    padding: 12px 16px;
    border-radius: 8px;
    background: white;
    color: #333;
}

.input-area input::placeholder { 
    color: #999; 
}

/* ========== 按钮样式 ========== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: #333;
    color: white;
}

.btn-primary:hover {
    background: #555;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* ========== 加载动画 ========== */
.typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing span {
    width: 8px;
    height: 8px;
    background: #333;
    border-radius: 50%;
    animation: typing 1s infinite;
}

.typing span:nth-child(2) { 
    animation-delay: 0.2s; 
}

.typing span:nth-child(3) { 
    animation-delay: 0.4s; 
}

@keyframes typing {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* ========== 搜索结果卡片 ========== */
.results-container {
    width: 100%;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: white;
    border-radius: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.result-info {
    flex: 1;
    min-width: 200px;
}

.result-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    font-size: 15px;
}

.result-meta {
    font-size: 13px;
    color: #666;
}

.result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.result-actions .btn {
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.15s;
}

.result-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ========== 分页组件 ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: #333;
    color: white;
    cursor: pointer;
}

.pagination button:hover {
    background: #555;
}

.pagination span {
    color: #666;
}

/* ========== 下载链接框 ========== */
.download-url-box {
    background: white;
    border-radius: 8px;
    padding: 20px;
    min-width: 280px;
    max-width: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.download-url-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 600;
    color: #333;
    font-size: 15px;
}

.download-url-link {
    background: #fafafa;
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    word-break: break-all;
    font-size: 14px;
    border: 1px solid #e0e0e0;
}

.download-url-link a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
}

.download-url-link a:hover {
    text-decoration: underline;
}

.download-url-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.download-url-actions button {
    flex: 1;
    text-align: center;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.15s;
}

.download-url-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.download-url-tip {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

@media (max-width: 600px) {
    .download-url-box {
        padding: 12px;
    }
    
    .download-url-header {
        font-size: 13px;
    }
    
    .download-url-link {
        padding: 10px;
        font-size: 12px;
    }
    
    .download-url-actions {
        gap: 8px;
    }
    
    .download-url-actions button {
        padding: 7px 10px;
        font-size: 12px;
    }
    
    .download-url-tip {
        font-size: 11px;
    }
}

/* ========== Toast 提示 ========== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
}

/* ========== 加载遮罩 ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== 页脚 ========== */
.footer {
    text-align: center;
    padding: 15px;
    color: #666;
    font-size: 12px;
}

.mobile-nav {
    display: none;
}

/* ========== 用户状态栏 ========== */
.user-status {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 10px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #333;
}

.user-status .vip-badge {
    background: #f39c12;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.user-status .free-badge {
    background: #333;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.vip-btn {
    background: #333;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.vip-btn:hover {
    background: #555;
}

/* ========== 模态框 ========== */
.vip-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.vip-modal.show {
    display: flex;
}

.vip-modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.vip-modal-content h3 {
    margin-bottom: 15px;
    color: #333;
}

.vip-modal-content input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
}

.vip-modal-content .btn {
    margin: 5px;
}

/* 推荐排行模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

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

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

.vip-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    text-align: left;
    font-size: 13px;
    color: #666;
}

/* ========== 响应式设计 - 移动端适配 ========== */
@media (max-width: 600px) {
    body { 
        padding: 0; 
    }
    
    .header { 
        padding: 10px;
        height: 22vh;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    .logo-container {
        position: relative;
        margin-bottom: 5px;
    }
    
    #siteLogo {
        width: 40px !important;
        height: 40px !important;
    }
    
    .header h1 { 
        font-size: 16px; 
        margin: 5px 0;
    }
    
    .header .stats { 
        gap: 10px; 
        margin: 5px 0;
        font-size: 11px;
    }
    
    .header .stat-value { 
        font-size: 14px; 
    }
    
    .header .stat-label {
        font-size: 10px;
    }
    
    .stat-item:nth-child(3),
    .stat-item:nth-child(4),
    .stat-item:nth-child(5) {
        display: none;
    }
    
    .user-status { 
        font-size: 10px; 
        gap: 6px; 
        padding: 6px 10px;
        flex-wrap: wrap;
        justify-content: center;
        margin: 5px 0;
    }
    
    .user-status .free-badge,
    .user-status .vip-badge {
        padding: 2px 6px;
        font-size: 10px;
    }
    
    .user-status .vip-btn {
        padding: 3px 6px;
        font-size: 10px;
    }
    
    .user-status #usageInfo {
        font-size: 10px;
    }
    
    .chat-container {
        position: fixed;
        top: calc(22vh);
        left: 0;
        right: 0;
        bottom: 56px;
        border-radius: 16px 16px 0 0;
    }
    
    .chat-messages {
        padding: 12px 10px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .message-bubble { 
        max-width: 90%; 
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 14px;
    }
    
    .message.user .message-bubble {
        border-bottom-right-radius: 4px;
    }
    
    .message.bot .message-bubble {
        border-bottom-left-radius: 4px;
    }
    
    .input-area {
        padding: 8px 12px;
        gap: 8px;
        bottom: 0;
        left: 0;
        right: 0;
        box-shadow: 0 -1px 3px rgba(0,0,0,0.08);
        display: flex;
        align-items: center;
    }
    
    .input-area select {
        padding: 8px;
        font-size: 12px;
        min-width: 80px;
        border-radius: 6px;
        border: 1px solid #ddd;
    }
    
    .input-area input {
        flex: 1;
        padding: 8px;
        font-size: 14px;
        border: none;
        outline: none;
    }
    
    .input-area button {
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    .result-item { 
        flex-direction: column; 
        align-items: flex-start;
        padding: 12px;
        margin: 8px 0;
        border-radius: 8px;
    }
    
    .result-name {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .result-meta {
        font-size: 12px;
    }
    
    .result-actions { 
        width: 100%; 
        display: flex;
        gap: 8px;
        margin-top: 10px;
    }
    
    .result-actions button,
    .result-actions a {
        flex: 1;
        text-align: center;
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .footer {
        padding: 8px;
        font-size: 11px;
    }
    
    .vip-modal-content {
        margin: 10px;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .footer {
        display: none;
    }
    
    /* 移动端底部导航 */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #eee;
        padding: 8px 0;
        z-index: 100;
        box-shadow: 0 -1px 5px rgba(0,0,0,0.05);
    }
    
    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 5px;
        cursor: pointer;
        transition: all 0.15s;
    }
    
    .mobile-nav-item.active {
        color: #333;
    }
    
    .mobile-nav-item:not(.active) {
        color: #999;
    }
    
    .nav-icon {
        font-size: 22px;
    }
    
    .nav-label {
        font-size: 11px;
    }
}

/* ========== 横屏适配 ========== */
@media (orientation: landscape) and (max-height: 600px) {
    .header {
        height: 28vh;
        padding: 10px;
    }
    
    .header h1 {
        font-size: 18px;
        margin: 5px 0;
    }
    
    .logo-container {
        margin-bottom: 5px;
    }
    
    #siteLogo {
        width: 35px !important;
        height: 35px !important;
    }
    
    .header .stats {
        gap: 15px;
        margin: 5px 0;
    }
    
    .header .stat-value {
        font-size: 14px;
    }
    
    .user-status {
        gap: 8px;
        padding: 6px 10px;
        margin: 5px 0;
    }
    
    .chat-container {
        top: calc(28vh);
        bottom: 60px;
    }
    
    .chat-messages {
        max-height: 100%;
        padding: 16px;
    }
    
    .input-area {
        padding: 8px 12px;
    }
    
    .input-area input {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .input-area button {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .message-bubble {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .result-item {
        padding: 12px;
        margin: 8px 0;
    }
    
    .result-name {
        font-size: 12px;
    }
    
    .result-meta {
        font-size: 11px;
    }
    
    .result-actions button,
    .result-actions a {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .nav-icon {
        font-size: 18px;
    }
    
    .nav-label {
        font-size: 9px;
    }
}

/* 加载动画 */
.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}