/* Theme Editor Styles */
.theme-editor {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent; /* Changed from rgba(0, 0, 0, 0.8) to allow seeing the site */
    pointer-events: none; /* Allow clicking through the transparent background */
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.theme-editor-panel {
    background: var(--bg-secondary);
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--border-color); /* Add border for better visibility */
    pointer-events: auto; /* Enable interaction with the panel */
    animation: slideUp 0.3s ease;
}

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

.theme-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 8px 8px 0 0;
}

.theme-editor-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.theme-editor-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
}

.theme-editor-close:hover {
    color: var(--danger);
}

.theme-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.theme-editor-info {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.theme-editor-info label {
    display: block;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.theme-editor-info input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
}

.theme-editor-info input[type="text"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.theme-editor-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.theme-editor-colors h3 {
    color: var(--text-primary);
    margin: 1.5rem 0 1rem 0;
    font-size: 1.1rem;
}

.color-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}


.color-field label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* Color Picker Styles */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

/* Ensure color field container has proper positioning context */
.color-field {
    display: flex;
    flex-direction: column;
    position: relative; /* Add positioning context for dropdown */
}

.color-picker-preview {
    width: 40px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

.color-picker-input {
    flex: 1;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.9rem;
}

.color-picker-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.color-picker-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: var(--bg-secondary);
    border: 2px solid var(--accent); /* Highlight border for visibility */
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 10001;
    padding: 1rem;
    min-width: 280px; /* Ensure minimum width */
}

.color-picker-panel {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.color-picker-canvas {
    border: 1px solid var(--border-color);
    cursor: crosshair;
}

.color-picker-hue,
.color-picker-alpha {
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.color-picker-inputs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.color-picker-inputs label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.color-picker-inputs input {
    width: 60px;
    padding: 0.2rem;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.color-picker-inputs input[type="number"] {
    width: 50px;
}

.color-picker-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.color-preset {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    cursor: pointer;
    transition: transform 0.1s;
}

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

/* Theme Editor Footer */
.theme-editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 0 0 8px 8px;
}

.theme-editor-footer button {
    min-width: 100px;
}

/* Theme Editor Presets Section */
.theme-editor-presets {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.theme-editor-presets h3 {
    margin-bottom: 1rem;
}

.theme-editor-presets button {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Theme Selector Modal */
.theme-selector-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3); /* Lighter overlay for theme selector */
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-selector-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
}

.theme-selector-content h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.theme-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.theme-item {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.theme-item:hover {
    background: var(--bg-tertiary);
}

.theme-item .badge {
    background: var(--accent);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Button Styles */
.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
    .theme-editor-panel {
        width: 95%;
        max-height: 95vh;
    }
    
    .color-group {
        grid-template-columns: 1fr;
    }
    
    .theme-editor-footer {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .theme-editor-footer button {
        width: 100%;
    }
}