@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Montserrat:wght@700;800&display=swap');

:root {
    /* 核心调色盘 - 现代科技风 */
    --bg-main: #0a0a0c;
    --bg-surface: #141418;
    --bg-card: rgba(26, 26, 31, 0.7);
    --bg-input: rgba(0, 0, 0, 0.3);

    --accent: #8b5ceb;
    --accent-glow: rgba(139, 92, 246, 0.4);
    --cyan: #06b6d4;
    --cyan-glow: rgba(6, 182, 212, 0.4);

    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-dim: #64748b;

    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(139, 92, 246, 0.3);

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    --glass-bg: rgba(20, 20, 24, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --blur: 12px;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
}

/* 顶部导航与语言切换 */
header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--cyan));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--accent-glow);
}

header h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.lang-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: 20px;
    display: flex;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lang-toggle:hover {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.1);
}

.lang-toggle span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
}

.lang-toggle span.active {
    color: var(--text-primary);
}

/* 主工作区布局 */
.workspace {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 30px;
    padding: 30px 40px;
    max-width: 1800px;
    margin: 0 auto;
}

/* 画布区域 */
.editor-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.canvas-card {
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.canvas-container {
    padding: 20px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

.upload-placeholder {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: var(--accent);
    margin-bottom: 20px;
    opacity: 0.8;
}

#canvas-wrapper {
    position: relative;
    max-width: 100%;
}

#canvas-wrapper img {
    max-width: 100%;
    display: block;
    user-select: none;
    pointer-events: none;
}

#drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: none;
    touch-action: none;
    z-index: 100;
}

.hidden {
    display: none !important;
}

/* 画布上方控件栏 */
.editor-toolbar {
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-input-container {
    width: 48px;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    cursor: pointer;
}

input[type="color"] {
    width: 150%;
    height: 150%;
    margin: -25%;
    cursor: pointer;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 25px;
    flex: 1;
    justify-content: center;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 80px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
    transition: all 0.2s ease;
}

/* 侧边栏卡片系统 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}

.badge {
    padding: 3px 10px;
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-body {
    padding: 25px;
}

.mask-preview-container {
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}

#mask-preview {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* 提示词控件 */
.illumination-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-row {
    display: flex;
    gap: 12px;
}

.control-group-flex {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.control-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.select-input,
.text-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
}

.select-input:focus,
.text-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.custom-inputs-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.add-custom-group {
    display: flex;
    gap: 10px;
}

.add-custom-group .btn {
    padding: 12px;
    width: 48px;
    flex-shrink: 0;
}

/* 按钮设计 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 8px 25px -5px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px -5px var(--accent-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
}

.btn-row {
    display: flex;
    gap: 15px;
    padding: 20px 25px;
    border-top: 1px solid var(--border);
}

.card-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border);
}

.flex-1 {
    flex: 1;
}

.full-width {
    width: 100%;
}

/* 多语言提示文本框 */
#generated-prompt {
    min-height: 120px;
    resize: none;
    background: #000;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: var(--cyan);
    line-height: 1.6;
}

/* Toast 通知 */
#toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--accent);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    pointer-events: none;
}

#toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* 画笔预览随动光标 */
#brush-cursor {
    pointer-events: none;
    position: fixed;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    display: none;
    mix-blend-mode: difference;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .workspace {
        grid-template-columns: 1fr;
    }
}

/* ToolBuddy Standard Components */

/* Integrated Header Home Button */
.nav-home-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    height: 32px;
    /* Match height of other header elements if needed, or let padding define it */
}

.nav-home-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--accent);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.nav-home-btn svg {
    color: var(--text-dim);
    transition: color 0.3s ease;
}

.nav-home-btn:hover svg {
    color: var(--accent);
}

/* Standard Footer */
.tb-footer {
    margin: 60px 0 20px;
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
    z-index: 10;
    width: 100%;
}

.tb-footer a {
    color: inherit;
    text-decoration: none;
    cursor: default;
}