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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* ===== 头部 ===== */
.app-header {
    background: linear-gradient(135deg, #161b22 0%, #0d1117 100%);
    border-bottom: 1px solid #30363d;
    padding: 16px 24px;
    text-align: center;
    flex-shrink: 0;
}

.app-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #f0f6fc;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.app-header p {
    font-size: 13px;
    color: #8b949e;
}

/* ===== 工作区布局 ===== */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1px;
    background: #30363d;
}

.sidebar {
    width: 260px;
    background: #161b22;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sidebar.left {
    border-right: 1px solid #30363d;
}

.sidebar.right {
    border-left: 1px solid #30363d;
}

.preview-area {
    flex: 1;
    background: #0d1117;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 16px;
    position: relative;
}

/* ===== 面板 ===== */
.panel {
    background: #161b22;
    padding: 16px;
    flex-shrink: 0;
}

.panel h3 {
    font-size: 13px;
    font-weight: 600;
    color: #f0f6fc;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #30363d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== 上传区 ===== */
.upload-zone {
    position: relative;
    border: 2px dashed #30363d;
    border-radius: 10px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #0d1117;
}

.upload-zone:hover {
    border-color: #58a6ff;
    background: rgba(88, 166, 255, 0.05);
}

.upload-zone.dragover {
    border-color: #3fb950;
    background: rgba(63, 185, 80, 0.1);
}

.upload-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

.upload-icon {
    font-size: 32px;
    opacity: 0.8;
}

.upload-hint span {
    font-size: 13px;
    color: #c9d1d9;
    font-weight: 500;
}

.upload-hint small {
    font-size: 11px;
    color: #6e7681;
}

/* ===== 素材列表 ===== */
.material-list {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.material-item {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #30363d;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s;
}

.material-item:hover {
    border-color: #58a6ff;
}

.material-item.active {
    border-color: #58a6ff;
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.3);
}

.material-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background:
        linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
    background-color: #0a0a0a;
}

.material-item .remove-btn {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    background: #da3633;
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.material-item:hover .remove-btn {
    opacity: 1;
}

.material-badge {
    position: absolute;
    left: 3px;
    bottom: 3px;
    height: 16px;
    padding: 0 5px;
    border-radius: 4px;
    background: rgba(35, 134, 54, 0.95);
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    font-weight: 700;
}

.material-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* ===== 模板列表 ===== */
.template-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.template-card {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.template-card:hover {
    border-color: #58a6ff;
    background: rgba(88, 166, 255, 0.05);
}

.template-card.active {
    border-color: #58a6ff;
    background: rgba(88, 166, 255, 0.1);
    box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.3);
}

.template-icon {
    font-size: 24px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #21262d;
    border-radius: 8px;
    flex-shrink: 0;
}

.template-info {
    flex: 1;
    min-width: 0;
}

.template-name {
    font-size: 13px;
    font-weight: 600;
    color: #f0f6fc;
    margin-bottom: 2px;
}

.template-desc {
    font-size: 11px;
    color: #6e7681;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-card .checkmark {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #238636;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.template-card.active .checkmark {
    opacity: 1;
}

/* ===== 参数面板 ===== */
.param-group {
    margin-bottom: 14px;
}

.param-group:last-child {
    margin-bottom: 0;
}

.param-group label {
    display: block;
    font-size: 12px;
    color: #8b949e;
    margin-bottom: 6px;
    font-weight: 500;
}

.param-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.param-row input[type="range"] {
    flex: 1;
}

.param-value {
    font-size: 12px;
    color: #58a6ff;
    font-weight: 600;
    min-width: 42px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.param-input {
    width: 100%;
    padding: 8px 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.param-input:focus {
    border-color: #58a6ff;
}

.param-input option {
    background: #0d1117;
    color: #c9d1d9;
}

/* Range input 样式 */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: #30363d;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #58a6ff;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #58a6ff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ===== 画布区域 ===== */
.canvas-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 0 1px #30363d, 0 8px 32px rgba(0, 0, 0, 0.5);
    background: #000;
    flex-shrink: 0;
}

#previewCanvas {
    display: block;
    background: #000;
}

.canvas-wrapper.transparent {
    background: 
        linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #0a0a0a;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #6e7681;
    background: rgba(0, 0, 0, 0.6);
}

.canvas-overlay.hidden {
    display: none;
}

/* ===== 控制按钮 ===== */
.controls {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid #30363d;
    background: #21262d;
    color: #c9d1d9;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    outline: none;
}

.btn.small {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    justify-content: center;
    min-height: 34px;
}

.btn:hover {
    background: #30363d;
    border-color: #8b949e;
}

.btn:active {
    transform: translateY(1px);
}

.btn.primary {
    background: #1f6feb;
    border-color: #1f6feb;
    color: #fff;
}

.btn.primary:hover {
    background: #388bfd;
    border-color: #388bfd;
}

.btn.success {
    background: #238636;
    border-color: #238636;
    color: #fff;
}

.btn.success:hover {
    background: #2ea043;
    border-color: #2ea043;
}

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

/* ===== 进度条 ===== */
.progress-bar {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: #21262d;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1f6feb, #58a6ff);
    border-radius: 3px;
    transition: width 0.1s ease;
    width: 0%;
}

.progress-text {
    font-size: 12px;
    color: #8b949e;
}

/* ===== 提示面板 ===== */
.tips ul {
    list-style: none;
    padding: 0;
}

.tips li {
    font-size: 12px;
    color: #6e7681;
    padding: 6px 0;
    padding-left: 16px;
    position: relative;
    line-height: 1.5;
}

.tips li::before {
    content: "•";
    position: absolute;
    left: 4px;
    color: #58a6ff;
}

.tips li + li {
    border-top: 1px solid #21262d;
}

/* ===== 参数开关/色块等 ===== */
.param-color {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid #30363d;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
}

.param-color input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    padding: 0;
    margin: -6px;
    cursor: pointer;
}

/* ===== 特效参数中的自定义项 ===== */
.effect-param-item {
    margin-bottom: 12px;
}

.effect-param-item label {
    display: block;
    font-size: 12px;
    color: #8b949e;
    margin-bottom: 6px;
}

.effect-param-item .param-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== 滚动条 ===== */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
    .workspace {
        flex-direction: column;
        overflow-y: auto;
    }
    
    .sidebar {
        width: 100%;
        max-height: 40vh;
    }
    
    .preview-area {
        min-height: 400px;
    }
}

/* ===== 动画提示 ===== */
@keyframes pulse-border {
    0%, 100% { border-color: #30363d; }
    50% { border-color: #58a6ff; }
}

.generating .canvas-wrapper {
    animation: pulse-border 1s ease infinite;
}

/* ===== 开关样式 ===== */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #30363d;
    transition: .2s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #c9d1d9;
    transition: .2s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #238636;
}

input:checked + .slider:before {
    transform: translateX(18px);
    background-color: #fff;
}

input:focus + .slider {
    box-shadow: 0 0 1px #238636;
}
