/* ============================================
   HTML托管 - shadcn/ui 设计风格
   MCP 美化组件: tabs / textarea / input / card / button / badge
   ============================================ */

/* --- CSS 变量 (shadcn 深色配色) --- */
:root {
    --bg: #0a0a0f;
    --bg-card: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.14);
    --text: #f1f5f9;
    --text-muted: rgba(255, 255, 255, 0.45);
    --text-muted-2: rgba(255, 255, 255, 0.25);
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-glow: rgba(129, 140, 248, 0.25);
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --radius: 12px;
    --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(129, 140, 248, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(244, 114, 182, 0.05) 0%, transparent 50%);
}

.container {
    width: 100%;
    max-width: 720px;
    padding: 40px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ============ 头部 ============ */

.header {
    text-align: center;
    margin-bottom: 32px;
}

.header-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(129, 140, 248, 0.3);
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.header p {
    font-size: 14px;
    color: var(--text-muted);
}

/* ============ 卡片 (shadcn Card) ============ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
    border-color: var(--border-hover);
}

.card-header {
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.card-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* ============ 选项卡 (shadcn Tabs) ============ */

.tabs-list {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    margin-bottom: 24px;
}

.tabs-trigger {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    user-select: none;
}

.tabs-trigger:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.tabs-trigger.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.tabs-trigger i {
    font-size: 15px;
}

.tabs-content {
    display: none;
}

.tabs-content.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ Textarea (shadcn) ============ */

.code-editor {
    width: 100%;
    min-height: 280px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', 'Menlo', monospace;
    line-height: 1.65;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.code-editor:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.1);
}

.code-editor::placeholder {
    color: var(--text-muted-2);
}

.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}

.char-count {
    font-size: 12px;
    color: var(--text-muted-2);
}

/* ============ 上传区域 (shadcn inspired) ============ */

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(129, 140, 248, 0.04);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(129, 140, 248, 0.08);
    transform: scale(1.01);
}

.upload-area .upload-icon {
    font-size: 40px;
    color: var(--text-muted);
    margin-bottom: 10px;
    transition: color 0.2s;
}

.upload-area:hover .upload-icon {
    color: var(--primary);
}

.upload-area .upload-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.upload-area .upload-hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* 已选择文件信息 */
.file-selected-card {
    display: none;
    padding: 16px 20px;
    background: rgba(129, 140, 248, 0.06);
    border: 1px solid rgba(129, 140, 248, 0.12);
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

.file-selected-card .file-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
    word-break: break-all;
}

.file-selected-card .file-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ============ 按钮 (shadcn Button) ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    color: #fff;
    box-shadow: 0 4px 16px rgba(129, 140, 248, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(129, 140, 248, 0.4);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    color: var(--text);
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.04);
}

.btn-sm {
    padding: 7px 16px;
    font-size: 13px;
}

.btn-danger {
    background: rgba(248, 113, 113, 0.12);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.18);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.2);
}

/* ============ 进度条 ============ */

.progress-wrapper {
    display: none;
    margin-top: 20px;
}

.progress-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    background: linear-gradient(90deg, #818cf8, #a78bfa);
    transition: width 0.3s ease;
}

.progress-label {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ============ 结果区域 ============ */

.result-area {
    display: none;
    text-align: center;
    margin-top: 24px;
}

.result-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(52, 211, 153, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--success);
    margin-bottom: 12px;
}

.result-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.result-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.link-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 12px;
}

.link-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    outline: none;
    width: 0;
}

.link-box .copy-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.link-box .copy-btn:hover {
    background: rgba(129, 140, 248, 0.1);
}

.result-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.countdown {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-muted-2);
}

.countdown strong {
    color: var(--warning);
}

/* ============ 页面详情 ============ */

.page-info-card {
    padding: 18px 20px;
    background: rgba(129, 140, 248, 0.05);
    border: 1px solid rgba(129, 140, 248, 0.1);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 20px;
}

.page-info-card strong {
    color: var(--text);
}

.preview-frame {
    width: 100%;
    height: 450px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    margin-top: 20px;
}

/* ============ 过期/协议页面 ============ */

.empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-state .empty-icon {
    font-size: 56px;
    color: var(--danger);
    opacity: 0.5;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 24px;
}

/* ============ 服务协议弹窗 ============ */

.terms-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.terms-overlay.hidden {
    display: none;
}

.terms-modal {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 40px 36px 32px;
    max-width: 460px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.35s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.terms-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    margin-bottom: 14px;
    box-shadow: 0 6px 24px rgba(129, 140, 248, 0.3);
}

.terms-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 16px;
}

.terms-modal-body {
    text-align: left;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.7;
    margin-bottom: 20px;
}

.terms-modal-body ul {
    margin: 8px 0 0 16px;
}

.terms-modal-body ul li {
    margin-bottom: 4px;
}

.terms-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    margin-bottom: 20px;
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.terms-checkbox:hover {
    background: rgba(255, 255, 255, 0.04);
}

.terms-checkbox input {
    display: none;
}

.check-mark {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.terms-checkbox input:checked + .check-mark {
    background: var(--primary);
    border-color: var(--primary);
}

.terms-checkbox input:checked + .check-mark::after {
    content: '\2713';
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.terms-modal .btn-primary {
    width: 100%;
    justify-content: center;
}

.terms-modal .btn-primary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ============ 页脚 ============ */

.footer {
    text-align: center;
    padding: 24px 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.15);
}

.footer a {
    color: rgba(255, 255, 255, 0.25);
    text-decoration: none;
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--primary);
}

/* ============ Toast ============ */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success {
    background: rgba(52, 211, 153, 0.12);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.18);
}

.toast-error {
    background: rgba(248, 113, 113, 0.12);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.18);
}

/* ============ 响应式 ============ */

@media (max-width: 576px) {
    .container { padding: 24px 16px; }
    .card { padding: 24px 16px; }
    .upload-area { padding: 32px 16px; }
    .header h1 { font-size: 20px; }
    .code-editor { min-height: 200px; font-size: 12px; }
    .preview-frame { height: 300px; }
    .terms-modal { padding: 28px 20px 24px; }
}
