/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #5B8DEE;
    --secondary-color: #7B68EE;
    --success-color: #48C774;
    --danger-color: #F14668;
    --text-primary: #2E3440;
    --text-secondary: #4C566A;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8F9FA;
    --bg-tertiary: #E9ECEF;
    --border-color: #DEE2E6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* 深色模式 */
[data-theme="dark"] {
    --text-primary: #ECEFF4;
    --text-secondary: #D8DEE9;
    --bg-primary: #2E3440;
    --bg-secondary: #3B4252;
    --bg-tertiary: #434C5E;
    --border-color: #4C566A;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 应用容器 */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-primary);
    min-height: 100vh;
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* 头部 */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: var(--shadow-md);
}

.app-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 主内容 */
.main-content {
    padding: 20px;
}

.section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.section h2 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 双列网格布局 */
.two-column-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.two-column-grid .section {
    margin-bottom: 0;
}

/* 按钮样式 */
.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    background: #4A7CD7;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.secondary-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.text-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.text-btn:hover {
    color: #4A7CD7;
    text-decoration: underline;
}

.copy-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.copy-btn:hover {
    background: var(--bg-secondary);
}

/* 1. 屏幕取色区域 */
.picker-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.shortcut-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

.current-color-display {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.color-preview {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    border: 3px solid white;
    box-shadow: var(--shadow-md);
    background: #FFFFFF;
}

.color-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 500;
    font-family: 'Courier New', monospace;
}

/* 2. 颜色转换区域 */
.convert-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.color-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.2s;
}

.color-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.convert-results {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    flex: 0 1 auto;
}

.result-item label {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
}

.result-item span {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* 3. 色轮选择器 */
.wheel-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.harmony-select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    background: white;
}

.wheel-container {
    display: flex;
    justify-content: center;
    margin: 24px 0;
}

#color-wheel-canvas {
    cursor: crosshair;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
}

.harmony-colors {
    display: flex;
    gap: 12px;
    margin: 24px 0;
    flex-wrap: wrap;
}

.harmony-color-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.harmony-color-box {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    border: 3px solid white;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.2s;
}

.harmony-color-box:hover {
    transform: scale(1.1);
}

.harmony-color-label {
    font-size: 12px;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
}

/* 4. 主题推荐 */
.theme-categories {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.theme-cat-btn {
    padding: 6px 14px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: var(--radius-md);
    font-size: 13px;
    cursor: pointer;
}

.theme-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.theme-card {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    background: white;
    cursor: pointer;
}

.theme-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.theme-card-name {
    font-weight: 600;
    font-size: 14px;
}

.theme-card-tag {
    font-size: 11px;
    padding: 3px 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.theme-colors {
    display: flex;
    gap: 4px;
}

.theme-color-swatch {
    flex: 1;
    height: 32px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

/* 5. 调色板管理 */
.palette-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.palette-card {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    background: white;
}

.palette-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.palette-name {
    font-weight: 600;
    font-size: 14px;
}

.palette-colors {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.palette-color-item {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

/* 6. 历史记录 */
.history-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0;
    max-height: 60px;
}

.history-list::-webkit-scrollbar {
    height: 6px;
}

.history-item {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

/* 取色遮罩层 */
.picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    cursor: crosshair;
}

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

.magnifier {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

#magnifier-canvas {
    border: 3px solid white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.magnifier-info {
    margin-top: 12px;
    font-size: 18px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.picker-hint {
    margin-top: 24px;
    color: white;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.6);
    padding: 12px 24px;
    border-radius: var(--radius-md);
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    min-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 20px;
}

.modal-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 20px;
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 响应式设计 */

/* 平板横屏及以下 (1024px) */
@media (max-width: 1024px) {
    .app-container {
        max-width: 100%;
        box-shadow: none;
    }

    #color-wheel-canvas {
        width: 250px;
        height: 250px;
    }
}

/* 平板竖屏及以下 (768px) */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 20px;
    }

    .main-content {
        padding: 16px;
    }

    .section {
        padding: 16px;
    }

    .section h2 {
        font-size: 18px;
    }

    /* 颜色转换 */
    .convert-input-group {
        flex-direction: column;
    }

    .convert-results {
        grid-template-columns: 1fr;
    }

    /* 色轮 */
    #color-wheel-canvas {
        width: 200px;
        height: 200px;
    }

    /* 主题列表 */
    .theme-list {
        grid-template-columns: 1fr;
    }

    /* 调色板 */
    .palette-list {
        grid-template-columns: 1fr;
    }

    /* 对比度检测 */
    .contrast-inputs {
        grid-template-columns: 1fr;
    }

    .contrast-result {
        flex-direction: column;
    }

    .contrast-preview-box {
        width: 100%;
        min-height: 100px;
    }

    .contrast-info {
        width: 100%;
    }

    /* 导出功能 */
    .export-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .export-source,
    .export-format {
        width: 100%;
    }

    /* 弹窗 */
    .modal-content {
        min-width: 320px;
        max-width: 90%;
        padding: 24px;
    }
}

/* 大屏手机及以下 (480px) */
@media (max-width: 480px) {
    .app-header {
        padding: 12px 16px;
    }

    .app-header h1 {
        font-size: 18px;
    }

    .header-actions {
        gap: 4px;
    }

    .icon-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .main-content {
        padding: 12px;
    }

    .section {
        padding: 12px;
        margin-bottom: 16px;
    }

    .section h2 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    /* 取色器 */
    .picker-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .current-color-display {
        flex-direction: column;
        text-align: center;
        padding: 12px;
    }

    .color-preview {
        width: 60px;
        height: 60px;
    }

    .color-info {
        font-size: 16px;
        flex-direction: column;
    }

    /* 按钮 */
    .primary-btn,
    .secondary-btn {
        padding: 8px 16px;
        font-size: 13px;
        width: 100%;
    }

    .shortcut-hint {
        font-size: 12px;
        text-align: center;
    }

    /* 颜色转换 */
    .result-item {
        flex-wrap: wrap;
        padding: 10px;
    }

    .result-item label {
        min-width: 50px;
        font-size: 13px;
    }

    .result-item span {
        font-size: 13px;
    }

    /* 色轮 */
    #color-wheel-canvas {
        width: 180px;
        height: 180px;
    }

    .harmony-colors {
        justify-content: center;
    }

    .harmony-color-box {
        width: 50px;
        height: 50px;
    }

    .harmony-color-label {
        font-size: 11px;
    }

    /* 主题分类按钮 */
    .theme-cat-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* 图片上传 */
    .image-upload-area {
        padding: 40px 15px;
    }

    .upload-icon {
        font-size: 36px;
    }

    .upload-prompt p {
        font-size: 14px;
    }

    #image-canvas {
        max-width: 100%;
        height: auto;
    }

    /* 对比度检测 */
    .contrast-preview-box {
        font-size: 16px;
    }

    .ratio-value {
        font-size: 24px;
    }

    .wcag-item {
        padding: 8px 10px;
    }

    .wcag-label {
        font-size: 13px;
    }

    .wcag-status {
        font-size: 12px;
        padding: 3px 8px;
    }

    /* 导出代码 */
    .code-output {
        font-size: 12px;
        padding: 12px;
        max-height: 300px;
    }

    /* 历史记录 */
    .history-item {
        width: 45px;
        height: 45px;
    }

    /* 调色板卡片 */
    .palette-card,
    .theme-card {
        padding: 12px;
    }

    /* 弹窗 */
    .modal-content {
        min-width: 280px;
        padding: 20px;
    }

    .modal-content h3 {
        font-size: 18px;
    }

    .modal-input {
        font-size: 14px;
        padding: 10px 12px;
    }

    .picker-hint {
        font-size: 14px;
        padding: 10px 16px;
    }
}

/* 超小屏幕 (360px) */
@media (max-width: 360px) {
    .app-header h1 {
        font-size: 16px;
    }

    .section h2 {
        font-size: 15px;
    }

    #color-wheel-canvas {
        width: 150px;
        height: 150px;
    }

    .harmony-color-box {
        width: 40px;
        height: 40px;
    }

    .extracted-color-box {
        width: 50px;
        height: 50px;
    }

    .palette-color-item {
        width: 35px;
        height: 35px;
    }

    .history-item {
        width: 40px;
        height: 40px;
    }
}


/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 1.5 图片提取颜色 */
.image-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-secondary);
}

.image-upload-area:hover {
    border-color: var(--primary-color);
    background: #F0F4FF;
}

.upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.upload-prompt p {
    margin: 4px 0;
    color: var(--text-primary);
    font-size: 13px;
}

.image-preview-container {
    margin-top: 12px;
}

.extracted-colors {
    margin-top: 12px;
}

.extracted-colors-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.extracted-color-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.extracted-color-box {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
}

.extracted-color-label {
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
}

/* 2.5 对比度检测 */
.section-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.contrast-inputs {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.contrast-color-input {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}

.contrast-color-input label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
}

.color-picker-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-picker-group input[type="color"] {
    width: 50px;
    height: 36px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.color-input-small {
    flex: 1;
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

.contrast-result {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.contrast-preview-box {
    width: 160px;
    height: 100px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.contrast-info {
    flex: 1;
    min-width: 250px;
}

.contrast-ratio {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.ratio-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.ratio-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

.wcag-ratings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.wcag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.wcag-label {
    font-size: 12px;
    color: var(--text-primary);
}

.wcag-status {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
}

.wcag-status.pass {
    color: var(--success-color);
    background: rgba(72, 199, 116, 0.1);
}

.wcag-status.fail {
    color: var(--danger-color);
    background: rgba(241, 70, 104, 0.1);
}

/* 2.6 导出为代码 */
.export-controls {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.export-source,
.export-format {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 160px;
}

.export-select {
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.code-output {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
    overflow-x: auto;
    max-height: 250px;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}
