/* ==========================================
   颜色名称生成器样式
   ========================================== */

/* 整体容器 */
.color-name-generator {
    margin-bottom: 30px;
}

/* 页面标题区 */
.color-name-generator-header {
    margin-bottom: 24px;
}

.color-name-generator-header h2 {
    font-size: 22px;
    color: #333;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-name-generator-subtitle {
    color: #888;
    font-size: 14px;
    margin: 0;
}

/* 工具主体 */
.cn-tool-body {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 30px;
}

/* 颜色输入区 */
.cn-input-section {
    padding: 30px;
    border-bottom: 1px solid #f0f0f0;
}

.cn-input-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

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

.cn-color-picker-wrapper input[type="color"] {
    width: 56px;
    height: 56px;
    padding: 4px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.cn-color-picker-wrapper input[type="color"]:hover,
.cn-color-picker-wrapper input[type="color"]:focus {
    border-color: #3498db;
}

.cn-text-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 160px;
}

.cn-text-input-wrapper input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.cn-text-input-wrapper input[type="text"]:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.cn-preview-swatch {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    background: #3498db;
    flex-shrink: 0;
    transition: background 0.2s;
}

/* 按钮行 */
.cn-btn-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.cn-btn {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    outline: none;
}

.cn-btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: #fff;
}

.cn-btn-primary:hover {
    background: linear-gradient(135deg, #2980b9, #1a6aa5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

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

.cn-btn-secondary {
    background: #f5f5f5;
    color: #555;
    border: 1px solid #ddd;
}

.cn-btn-secondary:hover {
    background: #eee;
    color: #333;
}

.cn-btn-copy {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
}

.cn-btn-copy:hover {
    background: linear-gradient(135deg, #27ae60, #1e8449);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
}

.cn-btn-random {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: #fff;
}

.cn-btn-random:hover {
    background: linear-gradient(135deg, #8e44ad, #7d3c98);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.4);
}

/* 预设色块 */
.cn-presets-section {
    padding: 0 30px 24px;
}

.cn-presets-label {
    font-size: 13px;
    color: #999;
    margin-bottom: 10px;
    font-weight: 500;
}

.cn-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cn-preset-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.cn-preset-swatch:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: #3498db;
}

/* 图片取色区 */
.cn-image-extract {
    margin: 0 30px 24px;
    padding: 20px;
    background: #fafafa;
    border-radius: 10px;
    border: 2px dashed #ddd;
}

.cn-image-extract-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    margin-bottom: 0;
}

.cn-image-extract-header h4 {
    font-size: 14px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.cn-image-extract.collapsed .cn-image-extract-content {
    display: none;
}

.cn-image-extract.collapsed .cn-toggle-icon {
    transform: rotate(-90deg);
}

.cn-toggle-icon {
    color: #999;
    transition: transform 0.2s;
}

.cn-image-extract-content {
    margin-top: 16px;
}

.cn-image-upload-area {
    position: relative;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
}

.cn-image-upload-area:hover,
.cn-image-upload-area.cn-dragover {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.04);
}

.cn-image-upload-area input[type="file"] {
    display: none;
}

.cn-upload-icon {
    font-size: 36px;
    color: #ccc;
    margin-bottom: 10px;
}

.cn-upload-text {
    color: #888;
    font-size: 14px;
    margin: 4px 0;
}

.cn-upload-hint {
    font-size: 12px;
    color: #bbb;
}

#cn-extract-canvas {
    display: none;
}

/* 结果面板 */
.cn-result-section {
    padding: 30px;
}

.cn-result-panel {
    display: none;
}

.cn-result-visible {
    display: block;
    animation: cn-fadein 0.3s ease;
}

@keyframes cn-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.cn-result-main {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.cn-color-display {
    width: 140px;
    height: 140px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.cn-color-preview {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    box-sizing: border-box;
}

.cn-color-hex {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 1px;
    font-family: 'Courier New', monospace;
}

.cn-result-info {
    flex: 1;
    min-width: 200px;
}

.cn-result-name {
    font-size: 28px;
    font-weight: 700;
    color: #222;
    margin-bottom: 8px;
    line-height: 1.2;
}

.cn-result-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.cn-source-tag,
.cn-confidence-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.cn-source-db {
    background: #e8f4fd;
    color: #2980b9;
}

.cn-source-ai {
    background: #fef0e7;
    color: #d35400;
}

.cn-confidence-tag {
    background: #f0f0f0;
    color: #666;
}

.cn-result-values {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.cn-value-item {
    background: #f8f8f8;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.cn-value-item:hover {
    background: #3498db;
    border-color: #3498db;
}

.cn-value-item:hover .cn-value-label,
.cn-value-item:hover .cn-value-text {
    color: #fff;
}

.cn-value-label {
    display: block;
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.cn-value-text {
    display: block;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    color: #333;
    letter-spacing: 0.5px;
}

.cn-result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* 相似颜色 */
.cn-similar-panel {
    margin-top: 30px;
}

.cn-similar-panel h4 {
    font-size: 14px;
    color: #888;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cn-similar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

.cn-similar-item {
    background: #f8f8f8;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.cn-similar-item:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.cn-similar-swatch {
    height: 60px;
}

.cn-similar-info {
    padding: 8px 10px;
    text-align: center;
}

.cn-similar-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.cn-similar-hex {
    display: block;
    font-size: 11px;
    color: #999;
    font-family: 'Courier New', monospace;
}

.cn-similar-confidence {
    display: block;
    font-size: 11px;
    color: #3498db;
    margin-top: 2px;
}

/* 加载状态 */
.cn-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 30px;
    color: #888;
    font-size: 14px;
}

.cn-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: cn-spin 0.8s linear infinite;
}

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

/* 错误提示 */
.cn-error-msg {
    padding: 20px;
    color: #e74c3c;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cn-empty {
    padding: 20px;
    color: #bbb;
    font-size: 14px;
    text-align: center;
}

/* Toast */
.cn-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 99999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

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

.cn-toast-success {
    background: #27ae60;
}

.cn-toast-error {
    background: #e74c3c;
}

.cn-toast-info {
    background: #333;
}

/* 响应式 */
@media (max-width: 600px) {
    .cn-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .cn-color-picker-wrapper {
        justify-content: center;
    }

    .cn-preview-swatch {
        width: 44px;
        height: 44px;
    }

    .cn-btn-row {
        flex-wrap: wrap;
    }

    .cn-btn {
        flex: 1;
        justify-content: center;
        min-width: 120px;
    }

    .cn-result-main {
        flex-direction: column;
        align-items: center;
    }

    .cn-color-display {
        width: 120px;
        height: 120px;
    }

    .cn-result-name {
        font-size: 22px;
        text-align: center;
    }

    .cn-result-values {
        justify-content: center;
    }

    .cn-result-actions {
        justify-content: center;
    }

    .cn-result-meta {
        justify-content: center;
    }
}
