/**
 * 文案生成页面样式
 * UI 重构：仅样式与结构层
 */

/* ===== 页面级全局滚动禁止 ===== */
html:has(.copywriting-page),
html:has(.copywriting-page) body {
    overflow: hidden !important;
    height: 100% !important;
}

html:has(.copywriting-page) .app-container {
    overflow: hidden !important;
}

/* ===== 页面整体 ===== */
.copywriting-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--navbar-height));
    height: calc(100dvh - var(--navbar-height));
    overflow: hidden;
    background: var(--color-bg-primary);
    color: rgba(255, 255, 255, 0.9);
}

/* ===== 顶部导航栏 ===== */
.copywriting-header,
.copy-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.copy-back-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    transition: background 0.2s;
    z-index: 1;
}

.copy-header-title,
.copywriting-header .page-header-title {
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    white-space: nowrap;
}

.copy-header-actions,
.copywriting-toolbar {
    display: flex;
    gap: 8px;
    margin-left: auto;
    z-index: 1;
}

.copy-header-actions button,
.copy-header-actions a,
.copywriting-toolbar .toolbar-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.78);
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    box-sizing: border-box;
}

.copy-back-btn:hover,
.copy-header-actions button:hover,
.copy-header-actions a:hover,
.copywriting-toolbar .toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ===== 输入/风格/生成固定区域 ===== */
.copywriting-input-area {
    flex-shrink: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--color-bg-primary);
}

.copy-input-section {
    padding: 20px 16px 0;
}

.copy-input-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 10px;
    font-weight: 500;
}

.copy-textarea-wrapper,
.textarea-wrapper {
    position: relative;
}

.copy-textarea,
.copywriting-textarea {
    width: 100%;
    min-height: 140px;
    max-height: 240px;
    height: 140px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    padding-right: 48px;
    font-size: 15px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.9);
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.copy-textarea:focus,
.copywriting-textarea:focus {
    border-color: rgba(245, 200, 66, 0.4);
    box-shadow: 0 0 0 3px rgba(245, 200, 66, 0.08);
}

.copy-textarea::placeholder,
.copywriting-textarea::placeholder {
    color: rgba(255, 255, 255, 0.2);
    font-size: 14px;
}

.copy-paste-btn,
.paste-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    color: rgba(255, 255, 255, 0.5);
}

.copy-paste-btn:hover,
.paste-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
}

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

.copy-char-count,
.char-count {
    text-align: right;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.2);
    margin-top: 6px;
    padding-right: 4px;
}

.copy-style-section {
    padding: 20px 16px 0;
}

.copy-style-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 12px;
    font-weight: 500;
}

.copy-style-group,
.copywriting-style-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.copy-style-btn,
.style-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.6);
    user-select: none;
}

.copy-style-btn .style-icon,
.style-chip .style-icon,
.style-chip .chip-icon {
    font-size: 22px;
    line-height: 1;
}

.copy-style-btn .style-name,
.style-chip .style-name,
.style-chip .chip-name {
    font-size: 13px;
    font-weight: 500;
}

.copy-style-btn:hover,
.style-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.copy-style-btn.active,
.style-chip.active {
    background: rgba(245, 200, 66, 0.1);
    border-color: rgba(245, 200, 66, 0.5);
    color: #F5C842;
    box-shadow: 0 2px 12px rgba(245, 200, 66, 0.12);
}

.copy-style-btn.active .style-name,
.style-chip.active .chip-name {
    color: #F5C842;
}

.copy-generate-section {
    padding: 20px 16px 0;
}

.copy-generate-btn,
.copywriting-generate-btn {
    width: 100%;
    padding: 14px 0;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #F5C842, #E8A317);
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
    box-shadow: 0 4px 16px rgba(245, 200, 66, 0.2);
}

.copy-generate-btn:hover,
.copywriting-generate-btn:hover {
    box-shadow: 0 6px 24px rgba(245, 200, 66, 0.3);
    transform: translateY(-1px);
}

.copy-generate-btn:active,
.copywriting-generate-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(245, 200, 66, 0.2);
}

.copy-generate-btn:disabled,
.copywriting-generate-btn:disabled,
.copy-generate-btn.loading,
.copywriting-generate-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.copy-cost-hint,
.copywriting-quota-hint {
    text-align: center;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.2);
    margin-top: 10px;
}

/* ===== 输入区折叠/展开过渡 ===== */
.copywriting-input-area {
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.copywriting-input-area .copy-textarea,
.copywriting-input-area .copywriting-textarea {
    transition: min-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.25s ease;
}

.copywriting-input-area .copy-style-section,
.copywriting-input-area .copy-generate-section,
.copywriting-input-area .copywriting-input-footer {
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s ease,
        margin 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 300px;
    overflow: hidden;
}

/* 折叠状态 — 直接隐藏所有子内容，只留 toggle 按钮 */
.copywriting-input-area.collapsed .copy-input-section,
.copywriting-input-area.collapsed .copy-style-section,
.copywriting-input-area.collapsed .copy-generate-section {
    display: none;
}

.copywriting-input-area.collapsed {
    padding-bottom: 0;
    border-bottom: none;
}

/* 展开/折叠切换按钮 */
.copy-toggle-btn {
    display: none;
    width: 100%;
    padding: 4px 16px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.2s;
    text-align: center;
    letter-spacing: 0.5px;
}

.copy-toggle-btn:hover {
    color: rgba(255, 255, 255, 0.7);
}

.copy-toggle-btn .toggle-icon {
    display: inline-block;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    margin-right: 4px;
}

/* 有结果时始终显示切换按钮（展开和折叠状态都可见） */
.copywriting-input-area.has-result .copy-toggle-btn {
    display: block;
}

.copywriting-input-area.collapsed .copy-toggle-btn .toggle-icon {
    transform: rotate(180deg);
}

/* ===== 结果区域 ===== */
.copywriting-result-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 0 12px;
    -webkit-overflow-scrolling: touch;
}

.copywriting-result-area::-webkit-scrollbar {
    width: 4px;
}

.copywriting-result-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.copy-result-card,
.copywriting-result-section {
    margin: 20px 16px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
}

.copy-result-header,
.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.result-title {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.78);
    font-weight: 600;
}

.result-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.copy-result-tag,
.badge {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 8px;
    background: rgba(245, 200, 66, 0.12);
    color: #F5C842;
    font-weight: 500;
    border: 1px solid rgba(245, 200, 66, 0.25);
}

.quick-copy-btn {
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-copy-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.copy-result-text,
.result-content {
    font-size: 14.5px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.85);
    white-space: pre-wrap;
    word-break: break-word;
}

.result-billing {
    margin-top: 10px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.38);
}

.copy-result-actions,
.result-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.copy-result-actions button,
.result-actions .btn-action {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.copy-result-actions button:hover,
.result-actions .btn-action:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* ===== 空状态 ===== */
.copy-empty-state,
.copywriting-empty-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 32px;
    text-align: center;
}

.copy-empty-icon,
.copywriting-empty-hint .empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: rgba(245, 200, 66, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin-bottom: 16px;
}

.copy-empty-title,
.copywriting-empty-hint .empty-text {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    font-weight: 500;
}

.copy-empty-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.25);
    line-height: 1.6;
    max-width: 260px;
}

/* ===== 弹窗样式（保留） ===== */
.history-item {
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.history-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.history-style {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);
}

.history-date {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

.history-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: var(--spacing-sm);
}

.history-actions {
    display: flex;
    gap: var(--spacing-sm);
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.history-actions button {
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-actions button:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-primary);
}

.empty-state {
    text-align: center;
    padding: var(--spacing-xxl);
    color: var(--color-text-tertiary);
    font-size: var(--font-size-md);
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: calc(var(--navbar-height) + var(--spacing-lg));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 1100;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {

    .copywriting-header,
    .copy-header {
        padding: 12px;
    }

    .copy-header-title,
    .copywriting-header .page-header-title {
        font-size: 16px;
    }

    .copy-input-section,
    .copy-style-section,
    .copy-generate-section {
        padding-left: 12px;
        padding-right: 12px;
    }

    .copy-textarea,
    .copywriting-textarea {
        min-height: 132px;
        height: 132px;
        font-size: 14px;
    }

    .copy-style-group,
    .copywriting-style-row {
        gap: 8px;
    }

    .copy-style-btn,
    .style-chip {
        padding: 12px 6px;
    }

    .copy-style-btn .style-icon,
    .style-chip .style-icon,
    .style-chip .chip-icon {
        font-size: 20px;
    }

    .copy-style-btn .style-name,
    .style-chip .style-name,
    .style-chip .chip-name {
        font-size: 12px;
    }

    .copy-result-card,
    .copywriting-result-section {
        margin: 16px 12px;
        padding: 14px;
    }

    .copy-result-actions,
    .result-actions {
        gap: 6px;
    }

    .copy-result-actions button,
    .result-actions .btn-action {
        font-size: 11px;
        padding: 8px 6px;
    }

    .copy-empty-state,
    .copywriting-empty-hint {
        padding: 36px 20px;
    }
}