/* ============================================
   MIUI X Design System - 拼豆图纸制作器
   设计语言: squircle圆角 / 卡片布局 / 毛玻璃
   主色: #FF6900 (小米橙)
   ============================================ */

:root {
    /* 主题色 */
    --primary: #FF6900;
    --primary-light: #FF8C3D;
    --primary-dark: #E55A00;
    --primary-bg: #FFF3E6;
    --primary-alpha: rgba(255, 105, 0, 0.08);
    --primary-alpha-hover: rgba(255, 105, 0, 0.12);

    /* 中性色 */
    --bg: #F5F5F7;
    --bg-card: #FFFFFF;
    --bg-card-hover: #FAFAFC;
    --bg-input: #F5F5F7;
    --bg-overlay: rgba(0, 0, 0, 0.4);

    /* 文字色 */
    --text-primary: #1A1A1A;
    --text-secondary: #6B6B6B;
    --text-tertiary: #9B9B9B;
    --text-white: #FFFFFF;

    /* 边框 */
    --border: rgba(0, 0, 0, 0.06);
    --border-strong: rgba(0, 0, 0, 0.1);

    /* 圆角 - MIUI squircle 风格 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* 阴影 - 柔和投影 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-primary: 0 4px 16px rgba(255, 105, 0, 0.3);

    /* 动画 */
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'MiSans', 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ============================================
   顶部导航
   ============================================ */
.miui-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-primary);
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover {
    background: var(--primary-alpha);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: var(--text-white);
}

/* ============================================
   Hero 区域
   ============================================ */
.hero-section {
    position: relative;
    padding: 60px 24px 40px;
    text-align: center;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 600px 300px at 30% 20%, rgba(255, 105, 0, 0.08), transparent),
        radial-gradient(ellipse 500px 250px at 70% 80%, rgba(255, 140, 61, 0.06), transparent);
}

.hero-content {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: 42px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #1A1A1A 0%, #4A4A4A 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.hero-badges {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.badge {
    padding: 6px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

/* ============================================
   主工作区
   ============================================ */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px 40px;
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
}

/* ============================================
   卡片基础样式
   ============================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.card-icon {
    font-size: 18px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-alpha);
    border-radius: var(--radius-sm);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.card-actions {
    display: flex;
    gap: 4px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--primary-alpha);
    color: var(--primary);
}

.icon-btn.active {
    background: var(--primary);
    color: #fff;
}

/* ============================================
   控制面板
   ============================================ */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 80px;
    align-self: start;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

/* 上传区域 */
.upload-zone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-alpha);
}

.upload-placeholder {
    color: var(--text-tertiary);
}

.upload-placeholder p {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 8px 0 4px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* 设置组 */
.setting-group {
    margin-bottom: 16px;
}

.setting-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.value-display {
    color: var(--primary);
    font-weight: 700;
}

.setting-hint {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary, #9a9a9f);
}

/* 品牌选择器 */
.brand-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.brand-chip {
    padding: 6px 12px;
    border: 1px solid var(--border-strong);
    background: var(--bg-card);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.brand-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.brand-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-white);
}

/* MIUI 滑块 */
.miui-slider,
.miui-slider-sm {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
}

.miui-slider-sm {
    height: 3px;
}

.miui-slider::-webkit-slider-thumb,
.miui-slider-sm::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 4px rgba(255, 105, 0, 0.15);
    transition: all var(--transition-fast);
}

.miui-slider-sm::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
}

.miui-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(255, 105, 0, 0.2);
}

.miui-slider::-moz-range-thumb,
.miui-slider-sm::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* 图片调整 */
.adjust-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.adjust-label {
    font-size: 12px;
    color: var(--text-tertiary);
    width: 40px;
    flex-shrink: 0;
}

.adjust-row .miui-slider-sm {
    flex: 1;
}

/* 开关 */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
}

.miui-toggle {
    width: 44px;
    height: 26px;
    background: #D8D8D8;
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    transition: background var(--transition);
}

.toggle-knob {
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: transform var(--transition-spring);
}

.miui-toggle.active {
    background: var(--primary);
}

.miui-toggle.active .toggle-knob {
    transform: translateX(18px);
}

/* 主按钮 */
.miui-btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--text-white);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-primary);
}

.miui-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 105, 0, 0.4);
}

.miui-btn-primary:active {
    transform: translateY(0);
}

.miui-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   预览区域
   ============================================ */
.preview-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.preview-card {
    overflow: hidden;
}

.canvas-wrapper {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-input);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    padding: 12px;
}

.canvas-wrapper canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

.pattern-canvas-wrapper {
    background:
        linear-gradient(45deg, #F0F0F0 25%, transparent 25%),
        linear-gradient(-45deg, #F0F0F0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #F0F0F0 75%),
        linear-gradient(-45deg, transparent 75%, #F0F0F0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* 空状态 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    color: var(--text-tertiary);
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-text {
    color: var(--text-tertiary);
    font-size: 15px;
}

/* ============================================
   材料清单
   ============================================ */
.material-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.summary-item {
    flex: 1;
    min-width: 100px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    text-align: center;
}

.summary-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.summary-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.material-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 400px;
    overflow-y: auto;
}

.material-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.material-item:hover {
    background: var(--primary-alpha);
}

.material-color {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid white;
    box-shadow: 0 0 0 1px var(--border-strong);
}

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

.material-code {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.material-name {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.material-count {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.material-percent {
    font-size: 11px;
    color: var(--text-tertiary);
    width: 40px;
    text-align: right;
    flex-shrink: 0;
}

/* ============================================
   色卡库
   ============================================ */
.color-library {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 24px;
}

.section-header {
    text-align: center;
    margin-bottom: 24px;
}

.section-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 14px;
}

.brand-tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.brand-tab {
    padding: 8px 16px;
    border: 1px solid var(--border-strong);
    background: var(--bg-card);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.brand-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.brand-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-white);
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.color-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
    cursor: pointer;
}

.color-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.color-swatch {
    width: 100%;
    aspect-ratio: 1;
}

.color-info {
    padding: 6px 8px;
    text-align: center;
}

.color-code {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}

.color-name {
    font-size: 9px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   底部
   ============================================ */
.miui-footer {
    text-align: center;
    padding: 32px 24px;
    color: var(--text-tertiary);
    font-size: 13px;
    border-top: 1px solid var(--border);
}

.miui-footer a {
    color: var(--primary);
    text-decoration: none;
}

/* ============================================
   加载遮罩
   ============================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
}

.loading-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 32px 48px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-input);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============================================
   Toast
   ============================================ */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--text-white);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-spring);
    z-index: 1001;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ============================================
   滚动条美化
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 960px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .control-panel {
        position: static;
        max-height: none;
    }

    .hero-title {
        font-size: 32px;
    }

    .header-content {
        padding: 0 16px;
    }

    .nav-link {
        padding: 6px 12px;
        font-size: 13px;
    }
}

@media (max-width: 600px) {
    .hero-title {
        font-size: 26px;
    }

    .hero-subtitle {
        font-size: 13px;
    }

    .badge {
        font-size: 11px;
        padding: 4px 10px;
    }

    .header-nav {
        gap: 2px;
    }
}
