/* 方舟财税知识库 - 样式表 */

/* ==================== 基础样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
}

.app {
    max-width: 750px;
    margin: 0 auto;
    min-height: 100vh;
    background: #fff;
    padding-bottom: 30px;
}

/* ==================== 头部 ==================== */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 18px 15px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.header-left, .header-right {
    flex-shrink: 0;
    min-width: 50px;
}

.header-left {
    text-align: left;
}

.header-right {
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.header-center {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    overflow: hidden;
}

.logo {
    font-size: 26px;
    flex-shrink: 0;
}

.title {
    font-size: 19px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-btn {
    font-size: 20px;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.settings-btn:hover {
    opacity: 1;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    white-space: nowrap;
}

.login-link {
    color: #fff;
    text-decoration: none;
    opacity: 0.9;
}

.login-link:hover {
    opacity: 1;
    text-decoration: underline;
}

.user-name {
    color: #fff;
    opacity: 0.95;
}

.logout-link {
    color: #ffd700;
    text-decoration: none;
    font-size: 12px;
}

.logout-link:hover {
    text-decoration: underline;
}

/* ==================== 问答摘要区域 ==================== */
.qa-section {
    padding: 20px 15px;
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
}

.qa-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.qa-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.qa-source-tag {
    font-size: 12px;
    color: #667eea;
    background: #f0f5ff;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
}

.qa-progress {
    font-size: 12px;
    color: #999;
}

.qa-question, .qa-answer {
    display: flex;
    margin-bottom: 15px;
}

.qa-label {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 12px;
}

.qa-question .qa-label {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: #fff;
}

.qa-answer .qa-label {
    background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
    color: #fff;
}

.qa-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.7;
    color: #333;
    padding-top: 4px;
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

/* 选中文字时高亮提示 */
.qa-text::selection {
    background: rgba(102, 126, 234, 0.3);
}

.qa-question .qa-text {
    font-weight: 500;
}

.qa-answer .qa-text {
    color: #555;
    white-space: pre-wrap;
}

.qa-actions {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px dashed #eee;
    display: flex;
    justify-content: center;
}

.qa-action-btn {
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

/* ==================== 导航按钮 ==================== */
.qa-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-top: 15px;
}

.qa-nav-btn {
    padding: 12px 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
}

.qa-nav-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
}

.qa-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ai-float-btn {
    padding: 12px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.ai-float-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* ==================== 加载状态 ==================== */
.qa-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.qa-loading p {
    color: #999;
    font-size: 14px;
}

/* ==================== 查看原文按钮 ==================== */
.view-original-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(82, 196, 26, 0.3);
}

.view-original-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(82, 196, 26, 0.4);
}

/* ==================== AI 问答入口 ==================== */
.ai-entry {
    margin: 15px;
    padding-top: 20px;
    border-top: 1px dashed #ddd;
}

.ai-entry-content {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 18px 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.ai-entry-content:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.ai-icon {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin-right: 15px;
}

.ai-text {
    flex: 1;
}

.ai-text h3 {
    color: #fff;
    font-size: 16px;
    margin-bottom: 5px;
}

.ai-text p {
    color: rgba(255,255,255,0.8);
    font-size: 13px;
}

.ai-arrow {
    color: #fff;
    font-size: 24px;
    opacity: 0.8;
}

/* ==================== 弹窗 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
}

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 750px;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 17px;
    color: #333;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    margin-left: 10px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    font-size: 15px;
    line-height: 1.8;
    color: #333;
}

.modal-body h2, .modal-body h3, .modal-body h4 {
    margin: 20px 0 10px 0;
    color: #333;
}

.modal-body h2 { font-size: 20px; }
.modal-body h3 { font-size: 17px; color: #667eea; }
.modal-body h4 { font-size: 15px; color: #764ba2; }

/* 弹窗底部AI按钮 */
.modal-ai-bar {
    display: none;
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.modal-ai-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-ai-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* 加载中 */
.loading-content {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* ==================== 文档全文 ==================== */
.doc-full-content {
    padding: 10px 0;
}

.doc-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.doc-section-content {
    font-size: 15px;
    line-height: 1.8;
    color: #444;
    white-space: pre-wrap;
}

/* ==================== 幻灯片播放器 ==================== */
.slide-player {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 400px;
}

.slide-indicator {
    text-align: center;
    padding: 10px;
    font-size: 14px;
    color: #667eea;
    font-weight: 600;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
}

.slide-img-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    border-radius: 16px;
    overflow: hidden;
    min-height: 400px;
    max-height: 600px;
}

.slide-img {
    max-width: 100%;
    max-height: 600px;
    object-fit: contain;
    border-radius: 8px;
}

.slide-error {
    color: #999;
    text-align: center;
    padding: 40px;
}

.slide-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    margin-top: 15px;
    border-top: 1px solid #eee;
}

.slide-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.slide-btn:disabled {
    background: #ddd;
    cursor: not-allowed;
}

.slide-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.slide-progress-text {
    font-size: 14px;
    color: #666;
}

/* ==================== AI 问答界面 ==================== */
.ai-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.ai-chat-container {
    max-width: 750px;
    margin: 0 auto;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.back-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
}

.ai-chat-header h2 {
    flex: 1;
    font-size: 17px;
    text-align: center;
}

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
}

.ai-welcome {
    text-align: center;
    padding: 40px 20px;
    background: #fff;
    border-radius: 16px;
    margin-bottom: 20px;
}

.ai-welcome-icon {
    font-size: 50px;
    margin-bottom: 15px;
}

.ai-welcome p {
    color: #666;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 10px;
}

.ai-welcome-hint {
    color: #999 !important;
    font-size: 13px !important;
}

.chat-message {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-message.ai .chat-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.chat-message.user .chat-avatar {
    background: #52c41a;
}

.chat-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
}

.chat-message.ai .chat-bubble {
    background: #fff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.chat-message.user .chat-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble.loading {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 15px 20px;
}

.chat-bubble.loading span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chat-bubble.loading span:nth-child(1) { animation-delay: -0.32s; }
.chat-bubble.loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.chat-source {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #999;
}

.chat-bubble.error {
    background: #fff2f0;
    color: #ff4d4f;
}

.ai-chat-input {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: #fff;
    border-top: 1px solid #eee;
}

.ai-chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
}

.ai-chat-input input:focus {
    border-color: #667eea;
}

.ai-chat-input button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    cursor: pointer;
}

/* ==================== 选中文本气泡 ==================== */
.selection-popup {
    position: fixed;
    z-index: 3000;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 4px;
}

.selection-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.empty-state p {
    color: #666;
    font-size: 15px;
    margin-bottom: 10px;
}

.empty-hint {
    color: #999 !important;
    font-size: 13px !important;
}

/* ==================== 移动端优化 ==================== */
@media (max-width: 480px) {
    .header {
        padding: 15px;
    }
    
    .title {
        font-size: 17px;
    }
    
    .qa-section {
        padding: 15px;
    }
    
    .qa-card {
        padding: 15px;
    }
    
    .qa-text {
        font-size: 14px;
    }
    
    .qa-nav {
        padding: 15px 0;
    }
    
    .qa-nav-btn {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .ai-float-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .slide-img-container {
        min-height: 300px;
        max-height: 450px;
    }
}

/* ==================== 全屏模式 ==================== */
.modal-content.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 100vh;
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    z-index: 1500;
    margin: 0;
}

.modal-content.fullscreen .modal-header {
    display: none;
}

.modal-content.fullscreen .modal-ai-bar {
    display: none !important;
}

.modal-content.fullscreen .modal-body {
    padding: 0;
    height: 100vh;
}

.modal-content.fullscreen .slide-player {
    height: 100vh;
    min-height: 100vh;
}

.modal-content.fullscreen .slide-img-container {
    max-height: none;
    min-height: 0;
    flex: 1;
    border-radius: 0;
}

.modal-content.fullscreen .slide-img {
    max-height: calc(100vh - 80px);
}

.modal-content.fullscreen .slide-indicator {
    display: none;
}

.modal-content.fullscreen .slide-controls {
    padding: 12px 15px;
    margin-top: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: #1a1a2e;
}

.modal-content.fullscreen .slide-btn {
    padding: 10px 18px;
}

.modal-content.fullscreen .slide-progress-text {
    color: #fff;
}

.modal-content.fullscreen .modal-body iframe {
    min-height: 100vh;
    height: 100vh;
}

.modal-content.fullscreen .doc-full-content {
    min-height: 100vh;
    padding: 20px;
}

.fullscreen-exit-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2000;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 14px 22px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255,255,255,0.2);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.fullscreen-exit-btn:active {
    background: rgba(0,0,0,0.9);
    transform: scale(0.95);
}

/* 手机竖屏时，全屏模式旋转为横屏展示 */
@media (orientation: portrait) and (max-width: 768px) {
    .modal-content.fullscreen {
        width: 100vh;
        height: 100vw;
        max-width: 100vh;
        max-height: 100vw;
        top: 50%;
        left: 50%;
        margin-top: calc(-50vw);
        margin-left: calc(-50vh);
        transform: rotate(90deg);
        transform-origin: center center;
    }

    .modal-content.fullscreen .slide-img {
        max-height: calc(100vw - 80px);
        max-width: 100%;
    }

    .modal-content.fullscreen .slide-img-container {
        max-height: calc(100vw - 80px);
    }

    .modal-content.fullscreen .modal-body iframe {
        min-height: 100vw;
        height: 100vw;
    }
}

.doc-fullscreen-bar {
    padding: 10px 15px;
    text-align: right;
    border-bottom: 1px solid #eee;
}

.doc-fullscreen-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.doc-fullscreen-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
