/* ============================================
   公众号配图工具样式 - WeChat Cover Maker Styles
   尺寸: 900px x 383px
   ============================================ */

:root {
    --accent: #2563eb;
    --panel-bg: #ffffff;
    --app-bg: #f3f4f6;
    --border: #e2e8f0;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--app-bg);
    overflow: hidden;
}

/* 左侧面板 */
aside {
    width: 380px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 10px 0 30px rgba(0,0,0,0.02);
}

.aside-header {
    padding: 24px;
    border-bottom: 1px solid #f1f5f9;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -1px;
}

.scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.group {
    margin-bottom: 24px;
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.group-label {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    margin-bottom: 16px;
    display: block;
    letter-spacing: 1px;
}

.ctrl-row {
    margin-bottom: 15px;
}

.ctrl-row label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 500;
}

.ctrl-row label span {
    color: var(--accent);
    font-family: monospace;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    -webkit-appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
}

textarea, select, input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background: #fff;
    transition: border-color 0.2s;
}

textarea:focus, select:focus, input[type="text"]:focus {
    border-color: var(--accent);
}

.btn-gen {
    background: #000;
    color: #fff;
    border: none;
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-gen:hover {
    background: #333;
    transform: translateY(-1px);
}

.btn-gen:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-sub {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
    margin-top: 8px;
    transition: all 0.2s;
}

.btn-sub:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: #fff1f2;
    color: #e11d48;
    border: 1px solid #fecdd3;
}

.btn-danger:hover {
    background: #ffe4e6;
}

/* 右侧预览区 */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
}

/* 核心卡片容器 - 公众号尺寸 900x383 */
#posterCard {
    width: 900px;
    height: 383px;
    background-color: #ffffff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 40px 100px -20px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
}

/* 独立的背景图层 */
#bgImageLayer {
    position: absolute;
    inset: 0;
    z-index: 1;
    background-size: cover;
    background-position: center;
    pointer-events: none;
}

/* 纸张纹理层 */
.paper-texture {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    opacity: 0.15;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* 内容层 */
.content-layer {
    position: relative;
    z-index: 10;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#illusWrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    overflow: hidden;
}

#illusImg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    mix-blend-mode: normal;
    filter: brightness(1.0) contrast(1.0);
}

#textWrapper {
    width: 100%;
    text-align: center;
    padding: 0 40px;
    z-index: 20;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(0);
}

#textDisplay {
    white-space: pre-wrap;
    word-break: break-all;
    width: 100%;
    display: block;
    color: #000;
}

#loadingOverlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.95);
    z-index: 100;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.export-btn {
    margin-top: 30px;
    background: #fff;
    border: 1px solid #000;
    padding: 12px 40px;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.export-btn:hover {
    background: #000;
    color: #fff;
}

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

.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%;
    position: relative;
}

/* 响应式 */
@media (max-width: 1400px) {
    #posterCard {
        width: 720px;
        height: 306px;
    }
}

@media (max-width: 968px) {
    aside {
        width: 100%;
        max-width: 100%;
    }
    
    main {
        padding: 10px;
    }
    
    #posterCard {
        width: 100%;
        max-width: 900px;
        height: auto;
        aspect-ratio: 900/383;
    }
}
