/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==================== 顶部导航 ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-right {
    display: flex;
    gap: 12px;
}

/* ==================== 按钮样式 ==================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg);
    border-color: var(--text-muted);
}

.btn-optimise {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
}

.btn-optimise:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-generate {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    margin-top: 16px;
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

/* ==================== 主内容区 ==================== */
.main {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    padding: 24px;
    flex: 1;
}

.panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.panel-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.input-panel,
.result-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==================== 表单样式 ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: var(--bg);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* ==================== 结果展示 ==================== */
.result-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 黄金开头 */
.golden-hook {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-left: 4px solid var(--warning);
    padding: 16px;
    border-radius: var(--radius-md);
}

.golden-hook-label {
    font-size: 12px;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.golden-hook-content {
    font-size: 16px;
    font-weight: 500;
    color: var(--primary);
    line-height: 1.7;
}

/* 分镜头 */
.scenes-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.scene-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all 0.2s;
}

.scene-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

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

.scene-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.scene-duration {
    font-size: 12px;
    color: var(--text-muted);
}

.scene-content {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.8;
    margin-bottom: 12px;
}

.scene-instructions {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.scene-instructions-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scene-instructions-content {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.instruction-tag {
    background: var(--bg);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
}

/* 价值强化 */
.value-strength {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-left: 4px solid var(--accent);
    padding: 16px;
    border-radius: var(--radius-md);
}

.value-strength-label {
    font-size: 12px;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 8px;
}

.value-strength-content {
    font-size: 14px;
    color: var(--primary);
    line-height: 1.7;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* ==================== 弹窗 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ==================== 历史记录 ==================== */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-item-title {
    font-weight: 500;
    color: var(--text-primary);
}

.history-item-date {
    font-size: 12px;
    color: var(--text-muted);
}

.history-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==================== 加载提示 ==================== */
.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}

.loading.active {
    display: flex;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    color: white;
    font-size: 14px;
}

/* ==================== 页脚 ==================== */
.footer {
    text-align: center;
    padding: 20px;
    margin-top: auto;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer p {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ==================== 响应式设计 ==================== */

/* 平板端 (768px - 1024px) */
@media (max-width: 1024px) {
    .main {
        grid-template-columns: 1fr;
    }

    .input-panel {
        max-height: none;
    }
}

/* 移动端通用 (<768px) */
@media (max-width: 768px) {
    /* 头部优化 */
    .header {
        padding: 12px 16px;
        position: relative;
    }

    .logo {
        font-size: 18px;
    }

    .logo::before {
        font-size: 20px;
    }

    .header-right {
        gap: 8px;
    }

    /* 按钮触摸优化 */
    .btn {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
        min-width: 44px;
    }

    .btn-sm {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 36px;
    }

    .btn-generate {
        padding: 14px 20px;
        font-size: 16px;
        margin-top: 20px;
    }

    /* 主内容区 */
    .main {
        padding: 16px;
        gap: 16px;
    }

    .panel-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .panel-header h2 {
        font-size: 15px;
    }

    .panel-body {
        padding: 16px;
    }

    .panel-actions {
        width: 100%;
        gap: 8px;
    }

    .panel-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* 表单优化 */
    .form-group {
        margin-bottom: 20px;
    }

    .form-group label {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .form-group input,
    .form-group textarea {
        padding: 12px 14px;
        font-size: 16px;
        border-radius: var(--radius-md);
    }

    /* 防止iOS缩放 */
    .form-group input {
        font-size: 16px;
    }

    .form-group textarea {
        min-height: 100px;
    }

    /* 结果展示优化 */
    .golden-hook,
    .value-strength {
        padding: 14px;
        border-radius: var(--radius-md);
    }

    .golden-hook-content {
        font-size: 15px;
    }

    .value-strength-content {
        font-size: 14px;
    }

    /* 分镜头优化 */
    .scene-item {
        padding: 14px;
    }

    .scene-content {
        font-size: 15px;
    }

    .scene-instructions {
        padding: 10px;
    }

    .scene-instructions-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .instruction-tag {
        font-size: 13px;
        padding: 6px 10px;
        width: 100%;
    }

    /* 弹窗优化 */
    .modal {
        padding: 16px;
    }

    .modal-content {
        max-height: calc(100vh - 32px);
        border-radius: var(--radius-lg);
    }

    .modal-large {
        max-width: 100%;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-header h3 {
        font-size: 15px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 14px 16px;
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1;
    }

    /* 历史记录优化 */
    .history-item {
        padding: 14px;
    }

    .history-item-title {
        font-size: 14px;
        flex: 1;
        word-break: break-word;
    }

    .history-item-preview {
        font-size: 13px;
    }

    /* 加载提示优化 */
    .loading-spinner {
        width: 56px;
        height: 56px;
    }

    .loading p {
        font-size: 15px;
        padding: 0 20px;
        text-align: center;
    }

    /* 页脚优化 */
    .footer {
        padding: 16px;
    }

    .footer p {
        font-size: 12px;
    }
}

/* 小屏手机 (<480px) */
@media (max-width: 480px) {
    .header {
        padding: 10px 12px;
    }

    .logo {
        font-size: 16px;
    }

    .header-right {
        flex-direction: column;
        width: 100%;
    }

    .header-right .btn {
        width: 100%;
        justify-content: center;
    }

    .main {
        padding: 12px;
        gap: 12px;
    }

    .panel-body {
        padding: 14px;
    }

    .btn-generate {
        padding: 14px 18px;
        font-size: 15px;
    }

    /* 分镜头指令标签两列布局 */
    .scene-instructions-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .instruction-tag {
        width: auto;
    }

    /* 空状态优化 */
    .empty-state {
        padding: 40px 16px;
    }

    .empty-icon {
        font-size: 40px;
    }
}

/* 超小屏 (<360px) */
@media (max-width: 360px) {
    .logo {
        font-size: 15px;
    }

    .main {
        padding: 10px;
    }

    .panel-header h2 {
        font-size: 14px;
    }

    .btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    .scene-instructions-content {
        grid-template-columns: 1fr;
    }
}

/* 横屏模式优化 */
@media (max-height: 600px) and (orientation: landscape) {
    .header {
        padding: 8px 16px;
    }

    .logo {
        font-size: 16px;
    }

    .main {
        padding: 12px;
        gap: 12px;
    }

    .panel-header {
        padding: 10px 14px;
    }

    .panel-body {
        padding: 12px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-group textarea {
        min-height: 60px;
    }

    .empty-state {
        padding: 30px 20px;
    }

    .empty-icon {
        font-size: 36px;
    }
}

/* iOS安全区域适配 */
@supports (padding: env(safe-area-inset-bottom)) {
    .modal-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .btn-generate {
        margin-bottom: env(safe-area-inset-bottom);
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn:active:not(:disabled) {
        transform: scale(0.97);
        opacity: 0.9;
    }

    .btn-generate:active:not(:disabled) {
        transform: scale(0.98) translateY(-1px);
    }

    .history-item:active {
        background: var(--bg);
    }

    .scene-item:active {
        border-color: var(--accent);
        background: var(--bg);
    }
}

/* 高DPI屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .golden-hook,
    .value-strength {
        border-left-width: 2px;
    }
}
