/* ===== 节假日海报生成器 — 简洁高级大气 ===== */

:root {
    --bg: #F8F9FA;
    --surface: #FFFFFF;
    --border: #E9ECEF;
    --text: #212529;
    --text-muted: #868E96;
    --accent: #2D6A4F;
    --accent-light: #D8F3DC;
    --danger: #E53E3E;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --radius: 10px;
    --radius-sm: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ===== 导航栏 ===== */
.topbar {
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-inner {
    max-width: 1440px;
    margin: 0 auto;
    height: 100%;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}
.model-tag {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ===== 主布局 ===== */
.layout {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 32px;
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 24px;
    min-height: calc(100vh - 56px);
}

/* ===== 侧边栏 ===== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== 面板 ===== */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.panel-title {
    padding: 14px 20px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge {
    background: var(--accent-light);
    color: var(--accent);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}
.panel-actions { margin-left: auto; display: flex; gap: 8px; }

/* ===== 节假日 Chips ===== */
.holiday-chips {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
}
.chip {
    flex: 1;
    padding: 10px 0;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    user-select: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

/* ===== 上传区 ===== */
.upload-area {
    margin: 12px 16px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--bg);
    position: relative;
    overflow: hidden;
}
.upload-area:hover { border-color: var(--accent); background: #f0faf4; }
.upload-idle { text-align: center; padding: 20px; }
.upload-icon { font-size: 28px; margin-bottom: 6px; opacity: 0.6; }
.upload-hint { font-size: 13px; color: var(--text-muted); }
.upload-done { position: relative; width: 100%; padding: 8px; display: flex; align-items: center; justify-content: center; }
.upload-done img { max-width: 100%; max-height: 140px; border-radius: var(--radius-sm); object-fit: contain; }
.upload-clear {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff; border: none;
    font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}

/* ===== 表单字段 ===== */
.field {
    padding: 0 16px;
    margin-bottom: 12px;
}
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.field input,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s;
    outline: none;
    resize: vertical;
    color: var(--text);
    background: var(--bg);
}
.field input:focus,
.field textarea:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(45,106,79,0.08);
}
.field textarea { min-height: 56px; }

/* ===== 下拉选择框 ===== */
.form-select {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    outline: none;
    transition: all 0.15s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23868E96' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.form-select:focus {
    border-color: var(--accent);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px rgba(45,106,79,0.08);
}

/* 自定义输入框 */
.custom-input {
    margin-top: 6px !important;
}

/* IP参考图徽章 */
.ip-ref-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    z-index: 5;
    animation: toastIn 0.3s ease;
}

/* ===== 生成按钮 ===== */
.btn-generate {
    width: calc(100% - 32px);
    margin: 12px 16px 16px;
    padding: 13px 0;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    letter-spacing: 0.02em;
}
.btn-generate:hover { filter: brightness(1.1); box-shadow: 0 4px 12px rgba(45,106,79,0.3); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; filter: none; box-shadow: none; }

/* ===== 右栏 ===== */
.workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ===== 提示词面板 ===== */
.prompt-panel { flex: 0 0 auto; }
.prompt-box {
    padding: 16px 20px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.prompt-box:empty::before {
    content: '配置左侧参数并生成海报，提示词将实时显示在这里…';
    color: var(--text-muted);
    font-style: italic;
}

/* ===== 图像面板 ===== */
.image-panel { flex: 1; display: flex; flex-direction: column; }
.image-area {
    flex: 1;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
}

/* 空状态 */
.empty-state {
    text-align: center;
    color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* 加载状态 */
.loading-state {
    text-align: center;
    color: var(--text-muted);
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state p { font-size: 15px; font-weight: 600; color: var(--text); }
.loading-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* 生成结果 */
.result-img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    object-fit: contain;
}

.local-path {
    margin-top: 8px;
    padding: 6px 12px;
    background: #f0f9f0;
    border-radius: 6px;
    font-size: 12px;
    color: #2d7a2d;
    text-align: center;
}

/* ===== 操作按钮 ===== */
.action-btn {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); }
.action-btn.accent {
    border-color: var(--accent);
    color: var(--accent);
}
.action-btn.accent:hover { background: var(--accent); color: #fff; }

/* ===== 消息提示 ===== */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    z-index: 999;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow-md);
}
.toast.success { background: var(--accent); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }

/* ===== 自定义节假日 ===== */
.custom-holiday-fields {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
    margin-top: 0;
    animation: slideDown 0.25s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.custom-holiday-fields .field { margin-bottom: 10px; }
.custom-holiday-fields .field label { color: var(--text-muted); font-size: 11px; }

/* ===== IP 卡片列表 ===== */
.ip-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px 16px;
}

.ip-card {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    overflow: hidden;
    transition: border-color 0.2s;
}
.ip-card.has-image { border-color: #b7d9c5; }
.ip-card.recognizing { border-color: #7C3AED; box-shadow: 0 0 0 2px rgba(124,58,237,0.15); }

.ip-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(0,0,0,0.02);
    border-bottom: 1px solid var(--border);
}
.ip-card-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}
.ip-card-label .ip-num {
    display: inline-flex;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
}
.ip-card-delete {
    width: 26px; height: 26px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.ip-card-delete:hover { background: #FEE2E2; color: var(--danger); }

.ip-card-body { padding: 10px 12px; }

.ip-card-upload {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--surface);
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}
.ip-card-upload:hover { border-color: var(--accent); background: #f0faf4; }
.ip-card-upload .upload-idle { text-align: center; padding: 10px; }
.ip-card-upload .upload-hint { font-size: 12px; color: var(--text-muted); }
.ip-card-upload .upload-icon { font-size: 22px; opacity: 0.5; }
.ip-card-upload .upload-done {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    width: 100%;
}
.ip-card-upload .upload-done img {
    max-width: 100%;
    max-height: 100px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}
.ip-card-upload .upload-clear {
    position: absolute;
    top: 4px; right: 4px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* IP 识别按钮 */
.ip-recognize-btn {
    width: 100%;
    padding: 8px 0;
    border: 1.5px solid #7C3AED;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #F5F3FF, #EDE9FE);
    color: #7C3AED;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 10px;
}
.ip-recognize-btn:hover {
    background: linear-gradient(135deg, #7C3AED, #6D28D9);
    color: #fff;
    box-shadow: 0 2px 10px rgba(124,58,237,0.3);
}
.ip-recognize-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
    box-shadow: none;
}
.ip-recognize-btn.has-result {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

/* IP 字段紧凑版 */
.ip-card-body .field {
    padding: 0;
    margin-bottom: 8px;
}
.ip-card-body .field:last-child { margin-bottom: 0; }
.ip-card-body .field label {
    font-size: 11px;
    margin-bottom: 3px;
}
.ip-card-body .field input,
.ip-card-body .field textarea {
    font-size: 12px;
    padding: 7px 10px;
}
.ip-card-body .field textarea { min-height: 48px; }

/* 添加 IP 按钮 */
.ip-add-btn {
    margin-left: auto;
    padding: 4px 12px;
    border: 1.5px dashed var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.ip-add-btn:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.ip-add-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== AI 生成按钮 ===== */
.ai-btn {
    margin-left: auto;
    padding: 5px 14px;
    border: 1.5px solid #7C3AED;
    border-radius: 20px;
    background: linear-gradient(135deg, #F5F3FF, #EDE9FE);
    color: #7C3AED;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.ai-btn:hover {
    background: linear-gradient(135deg, #7C3AED, #6D28D9);
    color: #fff;
    box-shadow: 0 2px 12px rgba(124,58,237,0.3);
}
.ai-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.ai-sparkle {
    font-size: 14px;
    animation: sparkle 1.5s ease-in-out infinite;
}
@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ===== AI 状态提示 ===== */
.ai-status {
    padding: 10px 16px;
    background: linear-gradient(135deg, #F5F3FF, #EDE9FE);
    border-top: 1px solid #DDD6FE;
}
.ai-status-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #7C3AED;
    font-weight: 600;
}
.spinner-sm {
    width: 16px; height: 16px;
    border: 2px solid #DDD6FE;
    border-top-color: #7C3AED;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

/* ===== 响应式 ===== */
@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; padding: 20px; }
    .topbar-inner { padding: 0 16px; }
}

/* ===== 历史记录面板 ===== */
.history-panel {
    flex: 0 0 auto;
    max-height: 260px;
    display: flex;
    flex-direction: column;
}
.history-panel .panel-title { flex-shrink: 0; }
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.history-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px 0;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    background: var(--surface);
}
.history-item:hover {
    border-color: var(--accent);
    background: #f0faf4;
}
.history-thumb {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg);
}
.history-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.history-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.history-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-time {
    font-size: 11px;
    color: var(--text-muted);
}
.history-download {
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.history-download:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}
