/* ===== Color Picker Compact Layout Styles ===== */
.color-picker-section {
    padding: 2rem 0;
}

.color-picker-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===== Main Picker Container - Two Column Layout ===== */
.picker-main-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    grid-template-rows: auto auto;
    gap: 2rem;
    align-items: start;
}

/* Position recommendations to span full width */
.color-recommendations-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    grid-column: 1 / -1; /* Span full width across both columns */
    grid-row: 2;
}

/* Ensure columns are in first row */
.canvas-recommendations-column {
    grid-column: 1;
    grid-row: 1;
}

.preview-codes-column {
    grid-column: 2;
    grid-row: 1;
}

/* ===== Left Column: Canvas + Recommendations ===== */
.canvas-recommendations-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
    grid-column: 1;
    grid-row: 1;
}

/* ===== Right Column: Preview + Codes ===== */
.preview-codes-column {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
    min-height: 520px; /* Match canvas container height */
    grid-column: 2;
    grid-row: 1;
}

/* ===== Color Canvas Container ===== */
.color-canvas-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-height: 520px; /* Set fixed height to match preview column */
    display: flex;
    flex-direction: column;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    text-align: center;
}

.canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.color-canvas {
    display: block;
    cursor: crosshair;
    border-radius: 8px;
    width: 100%;
    max-width: 300px;
    height: 300px;
}

.color-cursor {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* ===== Sliders ===== */
.hue-slider-container,
.alpha-slider-container {
    margin-bottom: 1rem;
}

.alpha-slider-container {
    margin-bottom: 0;
}

.slider-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
    margin-bottom: 0.5rem;
}

.hue-slider-wrapper,
.alpha-slider-wrapper {
    position: relative;
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
}

.hue-slider,
.alpha-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    z-index: 2;
}

.hue-slider::-webkit-slider-thumb,
.alpha-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid #333;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hue-slider::-moz-range-thumb,
.alpha-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid #333;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hue-slider-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right,
    #ff0000 0%,
    #ffff00 17%,
    #00ff00 33%,
    #00ffff 50%,
    #0000ff 67%,
    #ff00ff 83%,
    #ff0000 100%);
    border-radius: 10px;
    z-index: 1;
}

.alpha-slider-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent, #ff0000);
    border-radius: 10px;
    z-index: 1;
}

.alpha-slider-track::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: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    z-index: -1;
}

/* ===== Color Preview Section ===== */
.color-preview-section {
    flex-shrink: 0;
}

.color-preview-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.color-preview {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.preview-current {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.preview-transparent-bg {
    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: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    z-index: 1;
}

.preview-info {
    text-align: center;
}

.preview-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.preview-hex {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    font-family: 'Courier New', monospace;
}

/* ===== Color Codes Section ===== */
.color-codes-section {
    flex: 1;
}

.codes-grid {
    display: flow;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.code-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.code-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
}

.code-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    padding-bottom: 10px;
}

.code-input {
    flex: 1;
    padding: 0.75rem;
    padding-right: 2.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    background: #f8f9fa;
    transition: border-color 0.2s ease;
    width: 100%;
}

.code-input:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.1);
}

.copy-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #666;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    color: #0071e3;
    background: rgba(0, 113, 227, 0.1);
}

.copy-btn.copied {
    color: #28a745;
}

/* ===== Color Recommendations ===== */
.color-recommendations-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    grid-column: 1 / -1; /* Span full width across both columns */
}

.recommendations-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    flex: 1;
    min-width: 100px;
}

.tab-btn:hover {
    border-color: #0071e3;
    color: #0071e3;
}

.tab-btn.active {
    background: #0071e3;
    color: white;
    border-color: #0071e3;
}

.recommendations-content {
    position: relative;
}

.recommendation-group {
    display: none;
}

.recommendation-group.active {
    display: block;
}

.color-palette {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.palette-color {
    width: 90px;
    height: 90px;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    overflow: hidden;
}

.palette-color:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.palette-color::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: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    z-index: 1;
}

.palette-color::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.palette-color-code {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.65rem;
    padding: 2px 4px;
    text-align: center;
    font-family: 'Courier New', monospace;
    z-index: 3;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== Saved Colors ===== */
.saved-colors-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.saved-colors-palette {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    justify-content: center;
}

.saved-color {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    overflow: hidden;
}

.saved-color:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.saved-color::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: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
    z-index: 1;
}

.saved-color::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.saved-color-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.saved-color:hover .saved-color-remove {
    opacity: 1;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
    .picker-main-container {
        grid-template-columns: 1fr 320px;
        gap: 1.5rem;
    }

    .color-canvas {
        max-width: 250px;
        height: 250px;
    }

    .tab-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

@media (max-width: 768px) {
    .picker-main-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .preview-codes-column {
        order: -1;
    }

    .color-canvas {
        max-width: 280px;
        height: 280px;
    }

    .codes-grid {
        grid-template-columns: 1fr;
    }

    .recommendations-tabs {
        justify-content: center;
    }

    .tab-btn {
        flex: 1;
        min-width: 80px;
        font-size: 0.8rem;
    }

    .color-palette {
        justify-content: center;
    }

    .action-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .color-picker-container {
        gap: 1rem;
    }

    .color-canvas-container,
    .preview-codes-column,
    .color-recommendations-container,
    .saved-colors-container {
        padding: 1rem;
    }

    .palette-color {
        width: 50px;
        height: 50px;
    }

    .saved-color {
        width: 45px;
        height: 45px;
    }

    .codes-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

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

    .code-input {
        font-size: 0.8rem;
        padding: 0.6rem;
        padding-right: 2.5rem;
    }

    .tab-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
}

/* ===== Animation Classes ===== */
@keyframes colorPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.animate-pulse {
    animation: colorPulse 0.3s ease-in-out;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

/* ===== Tooltip Styles ===== */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.tooltip:hover::before {
    opacity: 1;
}

/* ===== Loading States ===== */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0071e3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Focus States for Accessibility ===== */
.color-canvas:focus,
.palette-color:focus,
.saved-color:focus {
    outline: 2px solid #0071e3;
    outline-offset: 2px;
}

.hue-slider:focus,
.alpha-slider:focus {
    outline: 2px solid #0071e3;
    outline-offset: 2px;
}

/* ===== Print Styles ===== */
@media print {
    .color-picker-container {
        box-shadow: none;
    }

    .action-buttons,
    .copy-btn {
        display: none;
    }

    .color-canvas-container,
    .preview-codes-column,
    .color-recommendations-container {
        border: 1px solid #ccc;
        break-inside: avoid;
    }
}

/* ===== Special Effects ===== */
.color-canvas:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease;
}

.code-input:hover {
    border-color: #bbb;
    transition: border-color 0.2s ease;
}

/* ===== Compact Mode Utilities ===== */
.compact-mode .color-preview {
    width: 80px;
    height: 80px;
}

.compact-mode .codes-grid {
    gap: 0.5rem;
}

.compact-mode .code-input {
    padding: 0.5rem;
    font-size: 0.8rem;
}

.compact-mode .palette-color {
    width: 50px;
    height: 50px;
}

/* ===== Enhanced Visual Polish ===== */
.preview-codes-column {
    position: sticky;
    top: 20px;
}

.canvas-recommendations-column {
    min-height: 0;
}

.color-recommendations-container {
    min-height: 200px;
}

/* ===== Improved Button Styling ===== */
.tab-btn {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* ===== Better Mobile Experience ===== */
@media (max-width: 768px) {
    .preview-codes-column {
        position: static;
        top: auto;
    }
}

/* ===== Dark Mode Support (Optional) ===== */
@media (prefers-color-scheme: dark) {
    .color-canvas-container,
    .preview-codes-column,
    .color-recommendations-container,
    .saved-colors-container {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    .section-title {
        color: #e0e0e0;
    }

    .code-input {
        background: #2a2a2a;
        border-color: #444;
        color: whitesmoke;
        font-size: 1.0rem;
    }

    .tab-btn {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }

    .tab-btn.active {
        background: #0071e3;
        color: white;
    }

    .preview-hex, .preview-label, .preview-label,
    .slider-label, .code-label {
        color: #d1cfcf;
    }
}

@media (prefers-color-scheme: light) {
    .color-canvas-container,
    .preview-codes-column,
    .color-recommendations-container,
    .saved-colors-container {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    .section-title {
        color: #e0e0e0;
    }

    .code-input {
        background: #2a2a2a;
        border-color: #444;
        color: whitesmoke;
        font-size: 1.0rem;
    }

    .tab-btn {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }

    .tab-btn.active {
        background: #0071e3;
        color: white;
    }

    .preview-hex, .preview-label, .preview-label,
    .slider-label, .code-label {
        color: #d1cfcf;
    }
}