/* Paper Generator - Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --error-color: #ef4444;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* Navbar */
.navbar {
    background: var(--card-bg);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
}

.nav-links a {
    margin-left: 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Card */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.card h1, .card h2, .card h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.card h1 {
    text-align: center;
    color: var(--primary-color);
}

/* Form */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.form-hint a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    margin-top: 1rem;
}

/* Links */
a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Center text */
.text-center {
    text-align: center;
    margin-top: 1rem;
}

/* Messages */
.message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
    display: none;
}

.message.success {
    display: block;
    background: #d1fae5;
    color: #065f46;
}

.message.error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
}

/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.feature-card {
    display: block;
    padding: 1.5rem;
    background: var(--background);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: transform 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.feature-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Result */
.result {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.paper-content {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 6px;
    white-space: pre-wrap;
    line-height: 1.8;
    max-height: 400px;
    overflow-y: auto;
}

/* History */
.history-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.history-item h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.history-item .meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.history-item .status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.status.success {
    background: #d1fae5;
    color: #065f46;
}

.status.error {
    background: #fee2e2;
    color: #991b1b;
}

/* 大纲预览 */
.outline-box {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.outline-box h3 {
    margin-top: 0;
    color: #495057;
}

.outline-box ol {
    margin: 10px 0 0 20px;
    padding: 0;
}

.outline-box li {
    margin: 8px 0;
    color: #6c757d;
}

/* 进度条 */
.progress-bar {
    margin: 20px 0;
}

.progress-text {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 10px;
    color: #495057;
}

.progress-text span {
    color: #4CAF50;
}

.progress-track {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 14px;
    color: #6c757d;
}

/* 打字效果 */
.paper-content.streaming::after {
    content: '▋';
    animation: blink 1s infinite;
    color: #4CAF50;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 论文内容区域优化 */
.paper-content {
    max-height: 600px;
    overflow-y: auto;
    padding: 20px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    line-height: 1.8;
}

.paper-content h2 {
    color: #2c3e50;
    margin-top: 30px;
    margin-bottom: 15px;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

.paper-content h2:first-child {
    margin-top: 0;
}

.paper-content p {
    margin: 15px 0;
    text-align: justify;
}

/* 操作按钮 */
.actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.actions button {
    margin: 0;
}

.download-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.download-group .btn {
    flex: 1;
    min-width: 140px;
    max-width: 200px;
}

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

    .download-group .btn {
        width: 100%;
        max-width: none;
    }
}

/* 确认模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
    overflow-y: auto;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 20px auto;
    padding: 1.5rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s;
    position: relative;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    text-align: center;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-body p {
    margin: 0.75rem 0;
    color: var(--text-primary);
    line-height: 1.6;
}

.modal-body strong {
    display: inline-block;
    min-width: 100px;
    color: var(--text-secondary);
}

.modal-body span {
    color: var(--text-primary);
}

/* Order number display */
.order-number-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    position: relative;
}

.order-number-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    margin: 0 0 0.3rem 0;
    font-weight: 500;
}

.order-number-value {
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    margin: 0 0 0.5rem 0;
    word-break: break-all;
    cursor: pointer;
    user-select: all;
    padding: 0.3rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.order-number-value:hover {
    background: rgba(255, 255, 255, 0.1);
}

.copy-hint {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    margin: 0.5rem 0 0 0;
    font-style: italic;
}

.btn-copy-order {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 0.75rem;
    transition: all 0.2s;
}

.btn-copy-order:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.btn-copy-order.copied {
    background: rgba(76, 175, 80, 0.4);
    border-color: rgba(76, 175, 80, 0.6);
}

.order-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

.order-warning strong {
    color: #d39e00;
}

/* Payment amount display */
.payment-amount-box {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-align: center;
}

.payment-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    margin: 0 0 0.3rem 0;
    font-weight: 500;
}

.payment-value {
    color: #ffffff;
    font-size: 1.8rem;
    font-weight: bold;
    margin: 0;
    letter-spacing: 1px;
}

/* Service terms */
.service-terms {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}

.service-terms p {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-weight: 500;
}

.service-terms ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.service-terms li {
    margin: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    background-color: var(--card-bg);
}

.modal-actions .btn {
    width: auto;
    min-width: 100px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Order Query Page Styles */
.order-info {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 6px;
}

.order-detail p {
    margin: 0.75rem 0;
    line-height: 1.8;
}

.order-detail strong {
    display: inline-block;
    min-width: 100px;
    color: var(--text-secondary);
}

.order-detail .status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
}

.order-detail .status.success {
    background: #d1fae5;
    color: #065f46;
}

.order-detail .status.error {
    background: #fee2e2;
    color: #991b1b;
}

.order-detail .status.info {
    background: #dbeafe;
    color: #1e40af;
}

/* Generating pulse animation */
.generating-pulse {
    animation: pulse-opacity 1.5s ease-in-out infinite;
}

@keyframes pulse-opacity {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.order-detail .error-text {
    color: var(--error-color);
    margin-top: 1rem;
    padding: 0.75rem;
    background: #fee2e2;
    border-radius: 4px;
}

.message.info {
    display: block;
    background: #dbeafe;
    color: #1e40af;
}

/* Payment Modal Styles */
.payment-modal-content {
    max-width: 500px;
}

.payment-info-box {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.payment-info-box p {
    margin: 0.5rem 0;
}

.payment-info-box .payment-amount {
    color: #f5576c;
    font-size: 1.3rem;
    font-weight: bold;
}

.qr-code-container {
    text-align: center;
    padding: 1.5rem;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.qr-code-image {
    width: 200px;
    height: 200px;
    margin: 0 auto;
    display: block;
}

.qr-hint {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.payment-countdown {
    text-align: center;
    padding: 0.75rem;
    background: #fff3cd;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.payment-countdown p {
    margin: 0;
    color: #856404;
    font-weight: 500;
}

.payment-countdown span {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: bold;
}

.payment-status {
    text-align: center;
    padding: 1rem;
    min-height: 80px;
}

.payment-checking {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-secondary);
}

.spinner-small {
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

.payment-success {
    color: var(--success-color);
}

.success-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--success-color);
    color: white;
    font-size: 2rem;
    line-height: 50px;
    margin: 0 auto 0.5rem;
}

.success-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.payment-timeout {
    color: #f59e0b;
}

.timeout-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.timeout-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.payment-tips {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}

.payment-tips p {
    margin: 0 0 0.5rem 0;
    font-weight: 500;
}

.payment-tips ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.payment-tips li {
    margin: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* Order Number Finder Component */
.order-finder-hint {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: white;
}

.order-finder-hint h4 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.order-finder-hint ul {
    margin: 0;
    padding-left: 1.5rem;
}

.order-finder-hint li {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.order-finder-hint a {
    color: white;
    text-decoration: underline;
    font-weight: 500;
}

.order-finder-hint a:hover {
    opacity: 0.9;
}

/* Continue Payment Button */
.btn-continue-payment {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
    width: 100%;
}

.btn-continue-payment:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

.order-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Collapsible Order Finder Hint */
.order-finder-hint-collapsible {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 4px;
}

.order-finder-hint-collapsible summary {
    cursor: pointer;
    font-weight: 500;
    color: #1976d2;
    user-select: none;
    list-style: none;
}

.order-finder-hint-collapsible summary::-webkit-details-marker {
    display: none;
}

.order-finder-hint-collapsible summary::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.2s;
}

.order-finder-hint-collapsible[open] summary::before {
    transform: rotate(90deg);
}

.order-finder-hint-collapsible ul {
    margin-top: 0.75rem;
    padding-left: 1.5rem;
}

.order-finder-hint-collapsible li {
    margin: 0.5rem 0;
    color: #424242;
    line-height: 1.6;
}

.order-finder-hint-collapsible a {
    color: #1976d2;
    text-decoration: underline;
}

/* Product Features */
.product-features {
    margin-bottom: 1.5rem;
    padding: 0.75rem 0;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.4rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.feature-check {
    color: var(--success-color);
    font-weight: 600;
    flex-shrink: 0;
}
