/**
 * 漸層產生器 CSS
 *
 * 顏色參考:
 * - 背景: #faf9f7
 * - 邊框: #e8e4dc
 * - 正文文字: #2d2a26
 * - 輔助文字: #5f5a56
 * - 金色強調: #d4af37
 */

/* ===== 主區域 ===== */
.gradient-main {
    display: flex;
    gap: 24px;
    margin-bottom: 1.5rem;
}

.gradient-controls {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gradient-preview-wrapper {
    flex: 1;
    min-width: 0;
}

/* ===== 顏色輸入面板 ===== */
.color-input-panel {
    background: #faf9f7;
    border: 1px solid #e8e4dc;
    border-radius: 12px;
    padding: 16px;
}

.color-input-panel h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2d2a26;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-input-panel h3 .color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #e8e4dc;
}

.color-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.color-picker-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
}

.color-picker-wrapper input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 2px solid #e8e4dc;
    border-radius: 8px;
    cursor: pointer;
    background: none;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

.hex-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #e8e4dc;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    color: #2d2a26;
    background: #fff;
    text-transform: uppercase;
}

.hex-input:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

/* ===== 角度調節面板 ===== */
.angle-panel {
    background: #faf9f7;
    border: 1px solid #e8e4dc;
    border-radius: 12px;
    padding: 16px;
}

.angle-panel h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2d2a26;
    margin: 0 0 12px 0;
}

.angle-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.angle-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e8e4dc;
    border-radius: 3px;
    outline: none;
}

.angle-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #d4af37;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.angle-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.angle-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #d4af37;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.angle-value {
    min-width: 60px;
    padding: 8px 12px;
    border: 1px solid #e8e4dc;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #2d2a26;
    background: #fff;
    text-align: center;
}

.angle-value:focus {
    outline: none;
    border-color: #d4af37;
}

.angle-presets {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.angle-preset-btn {
    padding: 6px 12px;
    border: 1px solid #e8e4dc;
    border-radius: 6px;
    background: #fff;
    font-size: 12px;
    color: #5f5a56;
    cursor: pointer;
    transition: all 0.2s;
}

.angle-preset-btn:hover {
    border-color: #d4af37;
    color: #d4af37;
}

.angle-preset-btn.active {
    background: #d4af37;
    border-color: #d4af37;
    color: #fff;
}

/* ===== 操作按鈕 ===== */
.gradient-actions {
    display: flex;
    gap: 8px;
}

.gradient-actions .tool-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-swap {
    background: #fff;
    border: 1px solid #e8e4dc;
    color: #5f5a56;
}

.btn-swap:hover {
    border-color: #d4af37;
    color: #d4af37;
}

.btn-random {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
}

.btn-random:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ===== 預覽區域 ===== */
.gradient-preview-box {
    background: #faf9f7;
    border: 1px solid #e8e4dc;
    border-radius: 12px;
    padding: 16px;
    height: 100%;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2d2a26;
    margin: 0;
}

.preview-display {
    flex: 1;
    border-radius: 12px;
    border: 1px solid #e8e4dc;
    min-height: 200px;
    position: relative;
    overflow: hidden;
}

/* 棋盤格背景（用於顯示透明度） */
.preview-display::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(45deg, #ddd 25%, transparent 25%),
        linear-gradient(-45deg, #ddd 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ddd 75%),
        linear-gradient(-45deg, transparent 75%, #ddd 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    opacity: 0.3;
}

.preview-gradient {
    position: absolute;
    inset: 0;
    border-radius: 11px;
}

/* ===== CSS代碼輸出 ===== */
.css-output-section {
    margin-bottom: 1.5rem;
}

.css-output-panel {
    background: #faf9f7;
    border: 1px solid #e8e4dc;
    border-radius: 12px;
    padding: 16px;
}

.css-output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.css-output-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2d2a26;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.css-output-header h3 i {
    color: #d4af37;
}

.css-code-box {
    background: #2d2a26;
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
}

.css-code-box code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #f8f8f2;
    white-space: pre-wrap;
    word-break: break-all;
}

.css-code-box .property {
    color: #66d9ef;
}

.css-code-box .value {
    color: #a6e22e;
}

/* ===== 預設區域 ===== */
.presets-section {
    margin-bottom: 1.5rem;
}

.presets-panel {
    background: #faf9f7;
    border: 1px solid #e8e4dc;
    border-radius: 12px;
    padding: 16px;
}

.presets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.presets-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2d2a26;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.presets-header h3 i {
    color: #d4af37;
}

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

.preset-item {
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.preset-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.preset-item.active {
    border-color: #d4af37;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.preset-item::after {
    content: attr(data-name);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 10px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.preset-item:hover::after {
    opacity: 1;
}

/* ===== 響應式 ===== */
@media (max-width: 768px) {
    .gradient-main {
        flex-direction: column;
    }

    .gradient-controls {
        flex: none;
        width: 100%;
    }

    .gradient-preview-box {
        min-height: 250px;
    }

    .gradient-actions {
        flex-direction: column;
    }

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

    .angle-presets {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .color-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .color-picker-wrapper {
        width: 100%;
        height: 48px;
    }

    .angle-control {
        flex-direction: column;
        align-items: stretch;
    }

    .angle-value {
        width: 100%;
    }
}
