/**
 * ColorPicker Component Styles
 * 颜色选择器组件样式
 * 
 * @version 1.0.0
 */

/* 主容器 */
.color-picker-container {
    position: relative;
    display: inline-block;
    z-index: 1000;
}

/* ===== Demo 页面样式（仅用于 color-picker.html）===== */
.test-container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.color-preview {
    width: 100px;
    height: 50px;
    border: 2px solid #ccc;
    margin: 10px 500px;
    border-radius: 5px;
}

.debug {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 5px;
    font-family: monospace;
    right: 20px;
    width: 300px;
    font-size: 12px;
    margin-top: 10px;
    margin: 10px 500px;
}

/* 颜色指示器和下拉箭头 */
.color-indicator-wrapper {
    position: relative;
    cursor: pointer;
    display: inline-block;
    padding: 4px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.color-indicator-wrapper:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.color-indicator-wrapper .color-indicator {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    background: #007aff;
    position: relative;
    overflow: hidden;
}

.color-indicator-wrapper .color-indicator::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #fff;
    display: none;
}

.color-picker-panel {
    position: fixed;
    /* top 和 left 将由 JavaScript 动态设置 */
    width: 210px;
    background: #ffffff;
    border-radius: 5px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    display: none;
    padding: 12px;
    box-sizing: border-box;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid #e0e0e0;
}

.color-picker-panel.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* 标签页切换 */
.color-picker-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.color-picker-tab {
    padding: 5px 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    position: relative;
    transition: color 0.2s;
}

.color-picker-tab:hover {
    color: #007aff;
}

.color-picker-tab.active {
    color: #007aff;
    font-weight: 600;
}

.color-picker-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: #007aff;
}

/* 单色选择面板 */
.color-picker-content {
    display: none;
}

.color-picker-content.active {
    display: block;
}

/* 颜色渐变方块 */
.color-gradient-area {
    width: 100%;
    height: 123px;
    border-radius: 4px;
    position: relative;
    cursor: crosshair;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    background: #f8f9fa;
}

.color-gradient-area canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 4px;
}

.color-picker-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: transparent;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
    transform: translate(-50%, -50%);
    pointer-events: none;
    top: 20%;
    left: 80%;
}

/* 色相滑块 */
.hue-slider-container {
    position: relative;
    height: 11px;
    width: 100%;
    border-radius: 3px;
    margin-bottom: 0;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    flex-shrink: 0;
}

.hue-slider-container canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 4px;
}

.hue-slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #ffffff;
    border-left: 1px solid rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(0, 0, 0, 0.3);
    transform: translateX(-50%);
    pointer-events: none;
    left: 70%;
}

/* 透明度滑块 */
.alpha-slider-container {
    position: relative;
    height: 11px;
    width: 100%;
    border-radius: 3px;
    margin-bottom: 0;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    flex-shrink: 0;
}

.alpha-slider-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 5px 5px;
    background-position: 0 0, 0 2.5px, 2.5px -2.5px, -2.5px 0px;
    border-radius: 3px;
}

.alpha-slider-container canvas {
    width: 100%;
    height: 100%;
    display: block;
    position: relative;
    z-index: 1;
    border-radius: 4px;
}

.alpha-slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #ffffff;
    border-left: 1px solid rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(0, 0, 0, 0.3);
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 2;
    left: 100%;
}

/* 颜色预览和输入区域 */
.color-preview-inputs {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 7px;
}

/* 滑块和预览行布局 */
.slider-preview-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

/* 滑块列：色相和透明度垂直排列 */
.sliders-column {
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* 两条滑块之间的间距，使总高度与吸管一致 */
    height: 24px;
    /* 色相(11) + 透明度(11) + 间距(2) = 24 */
    flex: 1;
}

/* 预览列：预览和吸管垂直排列 */
.preview-column {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    /* 保持与外层一致的水平间距 */
}

.color-preview-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    position: relative;
    flex-shrink: 0;
}

.color-preview-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 6px 6px;
    background-position: 0 0, 0 3px, 3px -3px, -3px 0px;
    z-index: 0;
    border-radius: 3px;
}

.color-preview-box .color-preview-inner {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #007aff;
    border: 1px solid #000;
    box-sizing: border-box;
    border-radius: 3px;
}

.eyedropper-btn {
    width: 24px;
    height: 24px;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 2px;
}

.eyedropper-btn:hover {
    background: #f5f5f5;
}

.eyedropper-btn.active {
    background: #007aff;
    border-color: #007aff;
}

.eyedropper-btn.active svg {
    stroke: #fff;
}

.eyedropper-btn svg {
    width: 20px;
    height: 20px;
}

/* 颜色值输入框 */
.color-inputs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.color-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.color-input-group label {
    font-size: 9px;
    color: #666;
    text-transform: uppercase;
}

#hexInput,
.color-input-group input#hexInput {
    width: 48px;
    font-family: monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
    text-align: left;
    box-sizing: border-box;
    padding: 2px 3px;
}

#linearHexInput,
.color-input-group input#linearHexInput {
    width: 48px;
    font-family: monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
    text-align: left;
    box-sizing: border-box;
    padding: 2px 3px;
}

#linearRInput,
#linearGInput,
#linearBInput,
#linearAInput,
.color-input-group input#linearRInput,
.color-input-group input#linearGInput,
.color-input-group input#linearBInput,
.color-input-group input#linearAInput {
    width: 28px;
    font-size: 10px;
    box-sizing: border-box;
    padding: 2px 3px;
}

.color-input-group input[type="number"] {
    width: 28px;
    padding: 2px 3px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    font-size: 10px;
    box-sizing: border-box;
}

/* 隐藏number输入框的箭头 */
.color-input-group input[type="number"]::-webkit-inner-spin-button,
.color-input-group input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.color-input-group input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.color-input-group input:focus {
    outline: none;
    border-color: #007aff;
}

/* 预设颜色色板 */
.color-swatches {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: space-between;
    padding-bottom: 2px;
    margin-top: 7px;
}

.color-swatches::-webkit-scrollbar {
    height: 4px;
}

.color-swatches::-webkit-scrollbar-track {
    background: transparent;
}

.color-swatches::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.color-swatch {
    width: 15px;
    height: 15px;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    flex: 1;
    max-width: 19px;
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 渐变选择面板 */
.gradient-controls {
    margin-bottom: 10px;
}

.gradient-stops {
    position: relative;
    width: 100%;
    height: 20px;
}

.gradient-stop {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 9px;
    height: 9px;
    border-radius: 2px;
    border: 1px solid transparent;
    cursor: move;
    z-index: 1;
    transition: transform 0.1s;
    overflow: hidden;
}

/* 棋盘格背景层 */
.gradient-stop::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 3px 3px;
    background-position: 0 0, 0 1.5px, 1.5px -1.5px, -1.5px 0px;
    background-color: #fff;
    z-index: 0;
}

/* 颜色层 - 通过CSS变量设置 */
.gradient-stop::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--stop-color, transparent);
    z-index: 1;
}

.gradient-stop:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

.gradient-stop.active {
    border-color: #007aff;
}

.gradient-preview-bar {
    position: relative;
    height: 15px;
    margin-bottom: 7px;
    border-radius: 3px;
    cursor: pointer;
    border: 1px solid #e0e0e0;
}

.gradient-stop-handle {
    position: absolute;
    top: 50%;
    width: 2px;
    height: 14px;
    background: #fff;
    border-radius: 1px;
    border: 1px solid #bbb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .09);
    transform: translate(-50%, -50%);
    cursor: ew-resize;
    z-index: 2;
}

.gradient-stop-handle.active {
    border-color: #007aff;
    background: #007aff;
}

.gradient-stop-handle-inner {
    display: none;
}

/* 角度控制 */
.angle-control {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.gradient-type-btns {
    display: flex;
    gap: 4px;
}

.gradient-type-btn {
    width: 20px;
    height: 20px;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
}

.gradient-type-btn:hover {
    background: #f5f5f5;
}

.gradient-type-btn.active {
    background: #c7c7c7;
}

.gradient-type-btn.active svg rect,
.gradient-type-btn.active svg circle {
    stroke: #fff;
}

.gradient-type-btn.active svg stop {
    stop-color: #fff;
}

.angle-control label {
    font-size: 9px;
    color: #333;
    min-width: 19px;
}

.angle-control input[type="number"] {
    width: 31px;
    padding: 2px 3px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    font-size: 10px;
    box-sizing: border-box;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* 隐藏角度输入框的箭头 */
.angle-control input[type="number"]::-webkit-inner-spin-button,
.angle-control input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.angle-control input[type="range"] {
    flex: 1;
    height: 5px;
    width: 60%;
}

.angle-control .angle-reset {
    width: 20px;
    height: 20px;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.angle-control .angle-reset:hover {
    background: #f5f5f5;
}