/**
 * Color Manager Popup Styles
 *
 * A floating popup for editing theme colors with live preview.
 * Part of the Color Management System - Phase 4.
 *
 * The popup is:
 * - Fixed positioned, centered initially
 * - Draggable via the header
 * - Scrollable content area
 * - High z-index to appear above all content
 */

/* ==================================================
   Main Container and Window
   ================================================== */

.color-manager-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.color-manager-popup.is-visible {
    /* Keep pointer-events: none on container so clicks pass through to app */
    /* Only the window itself (below) has pointer-events: auto */
    pointer-events: none;
}

.color-manager-window {
    position: absolute;
    width: 760px;
    max-width: calc(100vw - 40px);
    height: min(990px, calc(100vh - 60px));
    max-height: calc(100vh - 60px);
    min-height: 300px;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 12px;
    box-shadow:
        0 20px 50px rgba(15, 23, 42, 0.25),
        0 0 0 1px rgba(148, 163, 184, 0.15);
    pointer-events: auto;
    overflow: hidden;
    transform: translateY(0);
    transition: box-shadow 0.2s ease;
    resize: both;
}

.color-manager-window:hover {
    box-shadow:
        0 24px 60px rgba(15, 23, 42, 0.30),
        0 0 0 1px rgba(148, 163, 184, 0.18);
}

/* Minimized state */
.color-manager-popup.is-minimized .color-manager-window {
    max-height: 48px;
    overflow: hidden;
}

.color-manager-popup.is-minimized .color-manager-theme-row,
.color-manager-popup.is-minimized .color-manager-tabs,
.color-manager-popup.is-minimized .color-manager-content,
.color-manager-popup.is-minimized .color-manager-footer {
    display: none;
}

/* ==================================================
   Header
   ================================================== */

.color-manager-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.color-manager-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-manager-drag-icon {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
}

.color-manager-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.color-manager-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.color-manager-btn-minimize,
.color-manager-btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.color-manager-btn-minimize:hover,
.color-manager-btn-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.color-manager-btn-close:hover {
    background: rgba(239, 68, 68, 0.8);
}

/* Settings Button and Menu */
.color-manager-settings-wrapper {
    position: relative;
}

.color-manager-btn-settings {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.color-manager-btn-settings:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.color-manager-btn-settings[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.3);
}

.color-manager-settings-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 160px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 4px 0;
    z-index: 100002;
}

.color-manager-settings-menu.is-open {
    display: block;
}

.color-manager-settings-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #374151;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.color-manager-settings-item:hover {
    background: #f1f5f9;
}

.color-manager-settings-icon {
    font-size: 14px;
    color: #64748b;
}

/* Help Button and Keyboard Shortcuts Tooltip */
.color-manager-help-wrapper {
    position: relative;
}

.color-manager-btn-help {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.color-manager-btn-help:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.color-manager-btn-help[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.3);
}

.color-manager-help-tooltip {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 200px;
    background: #1e293b;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
    padding: 0;
    z-index: 100002;
    color: #e2e8f0;
    overflow: hidden;
}

.color-manager-help-tooltip.is-open {
    display: block;
}

.color-manager-help-tooltip-header {
    padding: 10px 12px;
    background: #334155;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.color-manager-help-tooltip-content {
    padding: 8px 0;
}

.color-manager-shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 13px;
}

.color-manager-shortcut-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.color-manager-shortcut-row kbd {
    display: inline-block;
    padding: 3px 6px;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 11px;
    font-weight: 500;
    background: #475569;
    border-radius: 4px;
    color: #f1f5f9;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.color-manager-shortcut-row span {
    color: #94a3b8;
}

/* ==================================================
   Theme Selector Row
   ================================================== */

.color-manager-theme-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.color-manager-theme-label {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
}

.color-manager-theme-select {
    flex: 1;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #1e293b;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.color-manager-theme-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.color-manager-unsaved-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 500;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
    animation: pulse-indicator 2s ease-in-out infinite;
}

.color-manager-unsaved-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #dc2626;
    border-radius: 50%;
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ==================================================
   Tabs
   ================================================== */

.color-manager-tabs {
    display: flex;
    padding: 0 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.color-manager-tab {
    flex: 1;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.color-manager-tab:hover {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.color-manager-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    background: #ffffff;
}

/* ==================================================
   Content Area
   ================================================== */

.color-manager-content {
    flex: 1;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.color-manager-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.color-manager-panel.active {
    display: flex;
}

/* ==================================================
   Split Panel Layout (Colors & Groups)
   ================================================== */

.color-manager-split-panel {
    flex-direction: row;
}

.color-manager-split-panel.active {
    display: flex;
}

.color-manager-split-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 1px solid #e2e8f0;
    overflow: hidden;
}

.color-manager-split-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ==================================================
   Controls Row (Search + Add)
   ================================================== */

.color-manager-controls-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.color-manager-search {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.color-manager-search::placeholder {
    color: #94a3b8;
}

.color-manager-search:focus {
    outline: none;
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.color-manager-btn-add {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-manager-btn-add:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

/* ==================================================
   Select All/None Controls
   ================================================== */

.color-manager-select-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.color-manager-link-btn {
    font-size: 12px;
    color: #3b82f6;
    background: none;
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease, text-decoration 0.15s ease;
}

.color-manager-link-btn:hover {
    color: #2563eb;
    text-decoration: underline;
}

.color-manager-separator {
    color: #cbd5e1;
    font-size: 12px;
}

.color-manager-selected-count {
    margin-left: auto;
    font-size: 12px;
    color: #64748b;
}

/* ==================================================
   Color List
   ================================================== */

.color-manager-color-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    min-height: 100px;
}

/* Custom scrollbar */
.color-manager-color-list::-webkit-scrollbar {
    width: 8px;
}

.color-manager-color-list::-webkit-scrollbar-track {
    background: var(--ui-sliders-scrollbars-scrollbarTrackBg, var(--color-gray-50));
}

.color-manager-color-list::-webkit-scrollbar-thumb {
    background: var(--ui-sliders-scrollbars-scrollbarThumbBg, var(--color-gray-300));
    border-radius: 4px;
}

.color-manager-color-list::-webkit-scrollbar-thumb:hover {
    background: var(--ui-sliders-scrollbars-scrollbarThumbHover, var(--color-blue-7));
}

.color-manager-color-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0px 12px;
    transition: background 0.15s ease;
}

.color-manager-color-item:hover {
    background: #f8fafc;
}

.color-manager-color-item.is-selected {
    background: #eff6ff;
}

.color-manager-color-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #3b82f6;
}

.color-manager-color-swatch {
    width: 130px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.color-manager-color-swatch:hover {
    transform: scale(1.03);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-manager-color-swatch-label {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
    max-width: 100%;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Assignment picking mode - crosshair cursor on swatches */
.color-manager-color-list.has-active-assignment .color-manager-color-swatch {
    cursor: crosshair;
}

.color-manager-color-list.has-active-assignment .color-manager-color-swatch:hover {
    transform: scale(1.06);
    box-shadow: 0 0 0 2px #3b82f6, 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Assignment picking highlight on the groups side */
.color-manager-assignment-item.is-picking {
    background: #eff6ff;
    box-shadow: inset 0 0 0 2px #3b82f6;
    border-radius: 6px;
}

.color-manager-color-name {
    flex: 1;
    font-size: 13px;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: none;
}

.color-manager-color-hex {
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
    color: #64748b;
    min-width: 70px;
}

/* Usage count badge */
.color-manager-usage-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 5px;
    border: none;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    background: #e0f2fe;
    color: #0369a1;
    flex-shrink: 0;
}

.color-manager-usage-badge:hover {
    background: #bae6fd;
    transform: scale(1.1);
}

.color-manager-usage-badge.unused {
    background: #fef2f2;
    color: #b91c1c;
}

.color-manager-usage-badge.unused:hover {
    background: #fee2e2;
}

/* Usage detail popup */
.color-manager-usage-popup {
    position: fixed;
    z-index: 100001;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
    padding: 10px 14px;
    min-width: 200px;
    max-width: 320px;
    max-height: 300px;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.color-manager-usage-popup-header {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
}

.color-manager-usage-popup-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.color-manager-usage-popup-list li {
    font-size: 12px;
    color: #475569;
    padding: 3px 0;
    border-bottom: 1px solid #f8fafc;
}

.color-manager-usage-popup-list li:last-child {
    border-bottom: none;
}

.color-manager-usage-popup-list li strong {
    color: #1e293b;
    font-weight: 600;
}

.color-manager-usage-popup-empty {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
}

/* Codebase usage badge (green pill — distinct from the blue group-assignment badge) */
.color-manager-codebase-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 5px;
    border: none;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    background: #dcfce7;
    color: #166534;
    flex-shrink: 0;
}

.color-manager-codebase-badge:hover {
    background: #bbf7d0;
    transform: scale(1.1);
}

.color-manager-codebase-badge.unused {
    background: #fef2f2;
    color: #b91c1c;
}

.color-manager-codebase-badge.unused:hover {
    background: #fee2e2;
}

/* Codebase usage detail popup */
.color-manager-codebase-popup {
    position: fixed;
    z-index: 100001;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
    padding: 10px 14px;
    min-width: 240px;
    max-width: 380px;
    max-height: 350px;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.color-manager-codebase-popup-header {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
}

.color-manager-codebase-aliases {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
}

.color-manager-codebase-aliases code {
    font-size: 10px;
    background: #f1f5f9;
    color: #475569;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'SFMono-Regular', Consolas, monospace;
}

.color-manager-codebase-popup-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.color-manager-codebase-popup-list li {
    font-size: 12px;
    color: #475569;
    padding: 3px 0;
    border-bottom: 1px solid #f8fafc;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.color-manager-codebase-popup-list li:last-child {
    border-bottom: none;
}

.color-manager-codebase-popup-list li .codebase-file-path {
    word-break: break-all;
}

.color-manager-codebase-popup-list li .codebase-file-count {
    font-weight: 600;
    color: #166534;
    white-space: nowrap;
}

.color-manager-codebase-popup-empty {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
}

.color-manager-color-edit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: #f1f5f9;
    border-radius: 6px;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.color-manager-color-edit:hover {
    background: #3b82f6;
    color: #ffffff;
}

.color-manager-color-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.color-manager-color-delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* Rename Button and Inline Editing */
.color-manager-rename-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 4px;
    color: #94a3b8;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.color-manager-rename-btn:hover {
    background: #f1f5f9;
    color: #3b82f6;
}

.color-manager-rename-container {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.color-manager-rename-input {
    flex: 1;
    min-width: 0;
    height: 26px;
    padding: 2px 6px;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    color: #1e293b;
    background: #ffffff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.color-manager-rename-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

.color-manager-rename-confirm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: #22c55e;
    border-radius: 4px;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.color-manager-rename-confirm:hover {
    background: #16a34a;
}

.color-manager-rename-cancel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: #ef4444;
    border-radius: 4px;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.color-manager-rename-cancel:hover {
    background: #dc2626;
}

.color-manager-rename-error {
    padding: 4px 16px;
    font-size: 12px;
    color: #dc2626;
    animation: slideDown 0.15s ease-out;
}

/* Delete Error and Confirm Dialogs */
.color-manager-color-error,
.color-manager-color-confirm {
    padding: 0 16px;
}

.delete-error-content {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    margin-bottom: 8px;
    animation: slideDown 0.2s ease-out;
}

.delete-error-icon {
    color: #dc2626;
    font-size: 16px;
    flex-shrink: 0;
}

.delete-error-text {
    flex: 1;
    font-size: 12px;
    color: #991b1b;
}

.delete-error-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: #dc2626;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.delete-error-close:hover {
    background: rgba(220, 38, 38, 0.1);
}

.delete-confirm-content {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 6px;
    margin-bottom: 8px;
    animation: slideDown 0.2s ease-out;
}

.delete-confirm-text {
    flex: 1;
    font-size: 12px;
    color: #854d0e;
}

.delete-confirm-yes,
.delete-confirm-no {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
}

.delete-confirm-yes {
    background: #dc2626;
    color: #ffffff;
}

.delete-confirm-yes:hover {
    background: #b91c1c;
}

.delete-confirm-no {
    background: #e5e7eb;
    color: #374151;
}

.delete-confirm-no:hover {
    background: #d1d5db;
}

/* Dark mode for delete dialogs */
body.dark .delete-error-content {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

body.dark .delete-error-icon {
    color: #f87171;
}

body.dark .delete-error-text {
    color: #fca5a5;
}

body.dark .delete-error-close {
    color: #f87171;
}

body.dark .delete-error-close:hover {
    background: rgba(239, 68, 68, 0.2);
}

body.dark .delete-confirm-content {
    background: rgba(253, 224, 71, 0.15);
    border-color: rgba(253, 224, 71, 0.3);
}

body.dark .delete-confirm-text {
    color: #fde68a;
}

body.dark .delete-confirm-no {
    background: #475569;
    color: #e2e8f0;
}

body.dark .delete-confirm-no:hover {
    background: #64748b;
}

/* Loading state */
.color-manager-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #64748b;
    font-size: 14px;
}

/* Empty state */
.color-manager-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #64748b;
    font-size: 14px;
    text-align: center;
}

/* ==================================================
   Batch Adjustment Panel
   ================================================== */

.color-manager-batch-panel {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.color-manager-batch-header {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 10px;
}

.color-manager-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.color-manager-slider-row label {
    width: 70px;
    font-size: 12px;
    color: #64748b;
}

.color-manager-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    appearance: none;
    cursor: pointer;
}

.color-manager-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-manager-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.color-manager-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.color-manager-slider-value {
    width: 40px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
    color: #475569;
    text-align: right;
}

/* Batch Panel Button Row */
.color-manager-batch-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.color-manager-batch-buttons .color-manager-btn-secondary,
.color-manager-batch-buttons .color-manager-btn-primary {
    flex: 1;
}

/* Save to Themes Dialog */
.save-to-themes-summary {
    font-size: 13px;
    color: #475569;
    margin-bottom: 12px;
}

.save-to-themes-select-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 12px;
}

.save-to-themes-select-controls a {
    color: #3b82f6;
    cursor: pointer;
    text-decoration: none;
}

.save-to-themes-select-controls a:hover {
    text-decoration: underline;
}

.save-to-themes-theme-list {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
}

.save-to-themes-theme-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: #334155;
}

.save-to-themes-theme-item:last-child {
    border-bottom: none;
}

.save-to-themes-theme-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    cursor: pointer;
}

.save-to-themes-theme-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.save-to-themes-theme-badge.active {
    background: #dbeafe;
    color: #1d4ed8;
}

.save-to-themes-theme-badge.default {
    background: #f0fdf4;
    color: #15803d;
}

/* ==================================================
   Group List (Chart Groups Tab)
   ================================================== */

.color-manager-group-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    min-height: 100px;
}

.color-manager-group-list::-webkit-scrollbar {
    width: 8px;
}

.color-manager-group-list::-webkit-scrollbar-track {
    background: var(--ui-sliders-scrollbars-scrollbarTrackBg, var(--color-gray-50));
}

.color-manager-group-list::-webkit-scrollbar-thumb {
    background: var(--ui-sliders-scrollbars-scrollbarThumbBg, var(--color-gray-300));
    border-radius: 4px;
}

.color-manager-group-item {
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s ease;
}

.color-manager-group-item:hover {
    background: #f8fafc;
}

.color-manager-group-item:last-child {
    border-bottom: none;
}

.color-manager-group-name {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    margin-bottom: 4px;
}

.color-manager-group-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #64748b;
}

.color-manager-group-type {
    padding: 2px 6px;
    background: #f1f5f9;
    border-radius: 3px;
}

.color-manager-group-type.chart {
    background: #eff6ff;
    color: #3b82f6;
}

.color-manager-group-type.ui {
    background: #f0fdf4;
    color: #16a34a;
}

.color-manager-group-colors {
    display: flex;
    gap: 2px;
    margin-top: 6px;
}

.color-manager-group-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Group Selector Dropdown */
.color-manager-group-selector {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.color-manager-group-selector label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 6px;
}

.color-manager-group-dropdown {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #1e293b;
    cursor: pointer;
}

.color-manager-group-dropdown:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.color-manager-group-dropdown optgroup {
    font-weight: 600;
    color: #475569;
}

.color-manager-group-dropdown option {
    font-weight: 400;
    padding: 4px 8px;
}

/* Group Details Area */
.color-manager-group-details {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.color-manager-group-instructions {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.color-manager-group-instructions p {
    margin: 0 0 12px 0;
    font-size: 13px;
    line-height: 1.5;
}

.color-manager-hint {
    font-size: 12px;
    color: #94a3b8;
    margin: 8px 0;
}

/* Group Header */
.color-manager-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.color-manager-group-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.color-manager-group-header .color-manager-group-type {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: #eff6ff;
    color: #3b82f6;
}

/* View Chart Button */
.color-manager-view-chart-btn {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    background: white;
    color: #3b82f6;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.color-manager-view-chart-btn:hover {
    background: #3b82f6;
    color: white;
}

.color-manager-view-chart-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.color-manager-view-chart-btn:active {
    transform: scale(0.98);
}

/* Assignments Section */
.color-manager-assignments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0 8px 0;
}

.color-manager-assignments-count {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
}

.color-manager-assignments-list {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow-y: auto;
    min-height: 100px;
}

/* Assignment Items */
.color-manager-assignment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 2px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s ease;
}

.color-manager-assignment-item:last-child {
    border-bottom: none;
}

.color-manager-assignment-item:hover {
    background: #f8fafc;
}

.color-manager-assignment-swatch-container {
    flex-shrink: 0;
}

.color-manager-assignment-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
    /* Checkerboard background for transparency visualization */
    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;
    position: relative;
}

.color-manager-assignment-swatch::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 3px;
    background-color: inherit;
}

.color-manager-assignment-info {
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.color-manager-assignment-label {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.color-manager-assignment-master-color {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}

.color-manager-assignment-opacity {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.color-manager-assignment-opacity-value {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    min-width: 40px;
    text-align: right;
}

/* Opacity Slider */
.color-manager-opacity-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    cursor: pointer;
    margin: 0;
}

.color-manager-opacity-slider:hover {
    background: #cbd5e1;
}

.color-manager-opacity-slider:focus {
    outline: none;
}

.color-manager-opacity-slider:focus-visible {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Slider thumb - WebKit browsers */
.color-manager-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.color-manager-opacity-slider::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.color-manager-opacity-slider:active::-webkit-slider-thumb {
    background: #1d4ed8;
    transform: scale(1.15);
}

/* Slider thumb - Firefox */
.color-manager-opacity-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #3b82f6;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.color-manager-opacity-slider::-moz-range-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.color-manager-opacity-slider:active::-moz-range-thumb {
    background: #1d4ed8;
    transform: scale(1.15);
}

/* Slider track - Firefox */
.color-manager-opacity-slider::-moz-range-track {
    background: #e2e8f0;
    border-radius: 2px;
    height: 4px;
}

/* Assignment Color Button */
.color-manager-assignment-color-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 1 0 auto;
}

.color-manager-assignment-color-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.color-manager-assignment-color-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
}

.color-manager-assignment-color-btn .color-manager-assignment-swatch-container {
    margin: 0;
}

.color-manager-assignment-color-name {
    display: flex;
    align-items: center;
    gap: 4px;
}

.color-manager-assignment-color-btn .color-manager-assignment-master-color {
    font-size: 11px;
    color: #475569;
    white-space: nowrap;
}

.color-manager-assignment-dropdown-arrow {
    font-size: 8px;
    color: #94a3b8;
    transition: transform 0.15s ease;
}

.color-manager-assignment-color-btn:hover .color-manager-assignment-dropdown-arrow {
    color: #64748b;
}

/* Color Grid Popup Backdrop */
.color-manager-color-grid-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
}

/* Color Grid Popup */
.color-manager-color-grid-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    max-height: 80vh;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2), 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.color-manager-color-selector-search {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.color-manager-color-selector-search-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
}

.color-manager-color-selector-search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.color-manager-color-selector-search-input::placeholder {
    color: #94a3b8;
}

.color-manager-color-selector-options {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 2px;
    align-content: start;
}

.color-manager-color-selector-empty {
    padding: 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    grid-column: 1 / -1;
}

.color-manager-color-option {
    padding: 8px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s ease, border-color 0.1s ease;
    line-height: 1.3;
    word-break: break-word;
}

.color-manager-color-option:hover {
    transform: scale(1.05);
    z-index: 1;
    filter: brightness(1.1);
}

.color-manager-color-option.focused {
    transform: scale(1.05);
    z-index: 1;
    filter: brightness(1.1);
}

.color-manager-color-option.is-current {
    border-color: #fff;
    box-shadow: 0 0 0 2px #3b82f6;
}

.color-manager-color-option:focus {
    outline: none;
}

/* Group Count */
.color-manager-group-count {
    padding: 8px 16px;
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    border-top: 1px solid #e2e8f0;
}

/* ==================================================
   Themes List (Themes Tab)
   ================================================== */

.color-manager-themes-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    min-height: 200px;
    max-height: 300px;
}

.color-manager-theme-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s ease;
}

.color-manager-theme-item:hover {
    background: #f8fafc;
}

.color-manager-theme-item.is-active {
    background: #eff6ff;
}

.color-manager-theme-item:last-child {
    border-bottom: none;
}

.color-manager-theme-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.color-manager-theme-name {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
}

.color-manager-theme-version {
    font-size: 11px;
    color: #64748b;
}

.color-manager-theme-badge {
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
}

.color-manager-theme-badge.default {
    background: #dbeafe;
    color: #1d4ed8;
}

.color-manager-theme-badge.active {
    background: #dcfce7;
    color: #15803d;
}

.color-manager-themes-header {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    padding: 8px 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-manager-theme-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.color-manager-theme-item.is-selected {
    background: #e0f2fe;
    border-left: 3px solid #0284c7;
}

.color-manager-theme-item.is-selected.is-active {
    background: #dcfce7;
    border-left: 3px solid #16a34a;
}

.color-manager-theme-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* ==================================================
   Footer
   ================================================== */

.color-manager-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.color-manager-footer-left,
.color-manager-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-manager-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 18px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.color-manager-btn-icon:hover:not(:disabled) {
    background: #f1f5f9;
    color: #3b82f6;
    border-color: #3b82f6;
}

.color-manager-btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.color-manager-btn-secondary {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.color-manager-btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

.color-manager-btn-primary {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-manager-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.color-manager-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.color-manager-btn-danger {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-manager-btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

.color-manager-btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ==================================================
   Loading Spinner
   ================================================== */

@keyframes color-manager-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.color-manager-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: color-manager-spin 0.8s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

.color-manager-btn-primary.is-loading {
    pointer-events: none;
    opacity: 0.8;
}

.color-manager-btn-primary.is-loading .color-manager-spinner {
    display: inline-block;
}

/* ==================================================
   Toast Notifications
   ================================================== */

.color-manager-toast {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    background: #1e293b;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.color-manager-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.color-manager-toast.success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.color-manager-toast.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.color-manager-toast.info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.color-manager-toast.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* ==================================================
   Color Picker Integration (for external library)
   ================================================== */

.color-manager-picker-container {
    position: absolute;
    z-index: 100001;
}

/* Animation for color highlight when changed */
@keyframes color-flash {
    0% { background: #fef9c3; }
    100% { background: transparent; }
}

.color-manager-color-item.just-changed {
    animation: color-flash 0.5s ease-out;
}

/* ==================================================
   Focus States for Accessibility
   ================================================== */

.color-manager-tab:focus-visible,
.color-manager-search:focus-visible,
.color-manager-theme-select:focus-visible,
.color-manager-btn-add:focus-visible,
.color-manager-btn-primary:focus-visible,
.color-manager-btn-secondary:focus-visible,
.color-manager-btn-icon:focus-visible,
.color-manager-btn-minimize:focus-visible,
.color-manager-btn-close:focus-visible,
.color-manager-link-btn:focus-visible,
.color-manager-color-edit:focus-visible,
.color-manager-color-delete:focus-visible,
.color-manager-rename-btn:focus-visible,
.color-manager-rename-confirm:focus-visible,
.color-manager-rename-cancel:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.color-manager-color-checkbox:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ==================================================
   Responsive Adjustments
   ================================================== */

@media (max-width: 480px) {
    .color-manager-window {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 40px);
    }

    .color-manager-header {
        padding: 10px 12px;
    }

    .color-manager-title {
        font-size: 14px;
    }

    .color-manager-theme-row {
        flex-wrap: wrap;
    }

    .color-manager-unsaved-indicator {
        width: 100%;
        margin-top: 8px;
        justify-content: center;
    }

    .color-manager-controls-row {
        flex-wrap: wrap;
    }

    .color-manager-btn-add {
        width: 100%;
        margin-top: 8px;
    }

    .color-manager-color-item {
        padding: 3px 10px;
    }

    .color-manager-color-hex {
        display: none;
    }

    .color-manager-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .color-manager-footer-left,
    .color-manager-footer-right {
        width: 100%;
        justify-content: center;
    }
}

/* ==================================================
   Dark Mode Support (when body has .dark class)
   ================================================== */

body.dark .color-manager-window {
    background: #1e293b;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

body.dark .color-manager-theme-row,
body.dark .color-manager-tabs,
body.dark .color-manager-footer,
body.dark .color-manager-batch-panel,
body.dark .color-manager-select-controls {
    background: #0f172a;
    border-color: #334155;
}

body.dark .color-manager-content {
    background: #1e293b;
}

body.dark .color-manager-split-left {
    border-right-color: #334155;
}

body.dark .color-manager-assignment-item.is-picking {
    background: rgba(59, 130, 246, 0.15);
    box-shadow: inset 0 0 0 2px #60a5fa;
}

body.dark .color-manager-color-list.has-active-assignment .color-manager-color-swatch:hover {
    box-shadow: 0 0 0 2px #60a5fa, 0 2px 8px rgba(96, 165, 250, 0.3);
}

body.dark .color-manager-theme-label,
body.dark .color-manager-batch-header,
body.dark .color-manager-slider-row label {
    color: #94a3b8;
}

body.dark .color-manager-theme-select,
body.dark .color-manager-search {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

body.dark .color-manager-theme-select:focus,
body.dark .color-manager-search:focus {
    border-color: #3b82f6;
    background: #1e293b;
}

body.dark .color-manager-tab {
    color: #94a3b8;
}

body.dark .color-manager-tab:hover {
    background: rgba(59, 130, 246, 0.1);
}

body.dark .color-manager-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
    background: #1e293b;
}

body.dark .color-manager-color-item:hover {
    background: #334155;
}

body.dark .color-manager-color-item.is-selected {
    background: rgba(59, 130, 246, 0.2);
}

body.dark .color-manager-color-name {
    color: #f1f5f9;
}

body.dark .color-manager-color-hex,
body.dark .color-manager-selected-count,
body.dark .color-manager-slider-value {
    color: #94a3b8;
}

body.dark .color-manager-usage-badge {
    background: #1e3a5f;
    color: #7dd3fc;
}

body.dark .color-manager-usage-badge:hover {
    background: #1e40af;
}

body.dark .color-manager-usage-badge.unused {
    background: #3b1c1c;
    color: #fca5a5;
}

body.dark .color-manager-usage-badge.unused:hover {
    background: #4b2020;
}

body.dark .color-manager-usage-popup {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

body.dark .color-manager-usage-popup-header {
    color: #e2e8f0;
    border-bottom-color: #334155;
}

body.dark .color-manager-usage-popup-list li {
    color: #94a3b8;
    border-bottom-color: #1e293b;
}

body.dark .color-manager-usage-popup-list li strong {
    color: #f1f5f9;
}

body.dark .color-manager-usage-popup-empty {
    color: #64748b;
}

body.dark .color-manager-codebase-badge {
    background: #14532d;
    color: #86efac;
}

body.dark .color-manager-codebase-badge:hover {
    background: #166534;
}

body.dark .color-manager-codebase-badge.unused {
    background: #3b1c1c;
    color: #fca5a5;
}

body.dark .color-manager-codebase-badge.unused:hover {
    background: #4b2020;
}

body.dark .color-manager-codebase-popup {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

body.dark .color-manager-codebase-popup-header {
    color: #e2e8f0;
    border-bottom-color: #334155;
}

body.dark .color-manager-codebase-aliases {
    border-bottom-color: #334155;
}

body.dark .color-manager-codebase-aliases code {
    background: #334155;
    color: #94a3b8;
}

body.dark .color-manager-codebase-popup-list li {
    color: #94a3b8;
    border-bottom-color: #1e293b;
}

body.dark .color-manager-codebase-popup-list li .codebase-file-count {
    color: #86efac;
}

body.dark .color-manager-codebase-popup-empty {
    color: #64748b;
}

body.dark .color-manager-color-edit {
    background: #334155;
    color: #94a3b8;
}

body.dark .color-manager-color-edit:hover {
    background: #3b82f6;
    color: #ffffff;
}

body.dark .color-manager-rename-btn {
    color: #64748b;
}

body.dark .color-manager-rename-btn:hover {
    background: #334155;
    color: #60a5fa;
}

body.dark .color-manager-rename-input {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #3b82f6;
}

body.dark .color-manager-rename-error {
    color: #f87171;
}

body.dark .color-manager-btn-icon {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}

body.dark .color-manager-btn-icon:hover:not(:disabled) {
    background: #475569;
    color: #60a5fa;
    border-color: #60a5fa;
}

body.dark .color-manager-btn-secondary {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark .color-manager-btn-secondary:hover {
    background: #475569;
    border-color: #64748b;
}

body.dark .color-manager-btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

body.dark .color-manager-btn-danger:hover {
    box-shadow: 0 4px 12px rgba(185, 28, 28, 0.4);
}

body.dark .color-manager-slider {
    background: #475569;
}

body.dark .color-manager-group-item {
    border-color: #334155;
}

body.dark .color-manager-group-item:hover {
    background: #334155;
}

body.dark .color-manager-group-name,
body.dark .color-manager-theme-name {
    color: #f1f5f9;
}

body.dark .color-manager-group-meta,
body.dark .color-manager-theme-version {
    color: #94a3b8;
}

body.dark .color-manager-group-type {
    background: #334155;
    color: #94a3b8;
}

body.dark .color-manager-group-type.chart {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

body.dark .color-manager-group-type.ui {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

body.dark .color-manager-group-selector {
    background: #1e293b;
    border-color: #334155;
}

body.dark .color-manager-group-selector label {
    color: #94a3b8;
}

body.dark .color-manager-group-dropdown {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark .color-manager-group-dropdown:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

body.dark .color-manager-group-details {
    background: #0f172a;
}

body.dark .color-manager-group-instructions {
    color: #94a3b8;
}

body.dark .color-manager-hint {
    color: #64748b;
}

body.dark .color-manager-group-header {
    border-color: #334155;
}

body.dark .color-manager-group-header h4 {
    color: #f1f5f9;
}

body.dark .color-manager-group-header .color-manager-group-type {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

body.dark .color-manager-view-chart-btn {
    background: #1e293b;
    border-color: #60a5fa;
    color: #60a5fa;
}

body.dark .color-manager-view-chart-btn:hover {
    background: #60a5fa;
    color: #0f172a;
}

body.dark .color-manager-view-chart-btn:focus-visible {
    outline-color: #60a5fa;
}

body.dark .color-manager-assignments-count {
    color: #94a3b8;
}

body.dark .color-manager-assignments-list {
    border-color: #334155;
}

body.dark .color-manager-assignment-item {
    border-color: #334155;
}

body.dark .color-manager-assignment-item:hover {
    background: #334155;
}

body.dark .color-manager-assignment-label {
    color: #f1f5f9;
}

body.dark .color-manager-assignment-master-color {
    color: #94a3b8;
}

body.dark .color-manager-assignment-opacity-value {
    color: #94a3b8;
}

/* Dark mode - Opacity Slider */
body.dark .color-manager-opacity-slider {
    background: #475569;
}

body.dark .color-manager-opacity-slider:hover {
    background: #64748b;
}

body.dark .color-manager-opacity-slider::-webkit-slider-thumb {
    background: #60a5fa;
}

body.dark .color-manager-opacity-slider::-webkit-slider-thumb:hover {
    background: #3b82f6;
}

body.dark .color-manager-opacity-slider:active::-webkit-slider-thumb {
    background: #2563eb;
}

body.dark .color-manager-opacity-slider::-moz-range-thumb {
    background: #60a5fa;
}

body.dark .color-manager-opacity-slider::-moz-range-thumb:hover {
    background: #3b82f6;
}

body.dark .color-manager-opacity-slider:active::-moz-range-thumb {
    background: #2563eb;
}

body.dark .color-manager-opacity-slider::-moz-range-track {
    background: #475569;
}

body.dark .color-manager-assignment-swatch {
    border-color: rgba(255, 255, 255, 0.15);
    /* Darker checkerboard for dark mode */
    background-image:
        linear-gradient(45deg, #4a5568 25%, transparent 25%),
        linear-gradient(-45deg, #4a5568 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #4a5568 75%),
        linear-gradient(-45deg, transparent 75%, #4a5568 75%);
}

/* Dark mode - Assignment Color Button */
body.dark .color-manager-assignment-color-btn {
    background: #334155;
    border-color: #475569;
}

body.dark .color-manager-assignment-color-btn:hover {
    background: #3f4f63;
    border-color: #64748b;
}

body.dark .color-manager-assignment-color-btn:focus {
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.4);
    border-color: #60a5fa;
}

body.dark .color-manager-assignment-color-btn .color-manager-assignment-master-color {
    color: #cbd5e1;
}

body.dark .color-manager-assignment-dropdown-arrow {
    color: #64748b;
}

body.dark .color-manager-assignment-color-btn:hover .color-manager-assignment-dropdown-arrow {
    color: #94a3b8;
}

/* Dark mode - Color Grid Popup */
body.dark .color-manager-color-grid-backdrop {
    background: rgba(0, 0, 0, 0.5);
}

body.dark .color-manager-color-grid-popup {
    background: #1e293b;
    border-color: #475569;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.3);
}

body.dark .color-manager-color-selector-search {
    border-color: #334155;
}

body.dark .color-manager-color-selector-search-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .color-manager-color-selector-search-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

body.dark .color-manager-color-selector-search-input::placeholder {
    color: #64748b;
}

body.dark .color-manager-color-selector-empty {
    color: #64748b;
}

body.dark .color-manager-color-option.is-current {
    border-color: #fff;
    box-shadow: 0 0 0 2px #60a5fa;
}

body.dark .color-manager-group-count {
    color: #64748b;
    border-color: #334155;
}

body.dark .color-manager-theme-item {
    border-color: #334155;
}

body.dark .color-manager-theme-item:hover {
    background: #334155;
}

body.dark .color-manager-theme-item.is-active {
    background: rgba(59, 130, 246, 0.2);
}

body.dark .color-manager-theme-item.is-selected {
    background: rgba(2, 132, 199, 0.25);
    border-left: 3px solid #0284c7;
}

body.dark .color-manager-theme-item.is-selected.is-active {
    background: rgba(22, 163, 74, 0.25);
    border-left: 3px solid #16a34a;
}

body.dark .color-manager-themes-header {
    color: #94a3b8;
}

body.dark .color-manager-theme-name {
    color: #e2e8f0;
}

body.dark .color-manager-theme-badge.default {
    background: rgba(29, 78, 216, 0.3);
    color: #93c5fd;
}

body.dark .color-manager-theme-badge.active {
    background: rgba(22, 163, 74, 0.3);
    color: #86efac;
}

body.dark .color-manager-loading,
body.dark .color-manager-empty {
    color: #94a3b8;
}

body.dark .color-manager-link-btn {
    color: #60a5fa;
}

body.dark .color-manager-link-btn:hover {
    color: #93c5fd;
}

body.dark .color-manager-separator {
    color: #475569;
}

/* ==================================================
   Pickr Color Picker Customizations
   ================================================== */

/* Ensure Pickr popup appears above everything */
.pcr-app {
    z-index: 100001 !important;
}

/* Custom styling for our color manager pickr instance */
.color-manager-pickr.pcr-app {
    font-family: inherit;
    border-radius: 8px;
    box-shadow:
        0 10px 25px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(0, 0, 0, 0.1);
}

.color-manager-pickr .pcr-interaction input {
    border-radius: 4px;
}

.color-manager-pickr .pcr-interaction .pcr-save,
.color-manager-pickr .pcr-interaction .pcr-cancel {
    border-radius: 4px;
    font-weight: 500;
}

.color-manager-pickr .pcr-interaction .pcr-save {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
}

.color-manager-pickr .pcr-interaction .pcr-cancel {
    background: #64748b !important;
}

/* Pickr dark mode adjustments */
body.dark .color-manager-pickr.pcr-app {
    background: #1e293b;
    box-shadow:
        0 10px 25px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

body.dark .color-manager-pickr .pcr-interaction input {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

body.dark .color-manager-pickr .pcr-interaction input:focus {
    border-color: #3b82f6;
}

/* Make color swatch highlight when being edited */
.color-manager-color-item.is-editing .color-manager-color-swatch {
    box-shadow:
        0 0 0 2px #3b82f6,
        0 2px 8px rgba(59, 130, 246, 0.3);
    transform: scale(1.1);
}

/* Flash animation when color changes */
.color-manager-color-item.color-changed .color-manager-color-swatch {
    animation: swatch-pulse 0.3s ease-out;
}

@keyframes swatch-pulse {
    0% {
        box-shadow:
            0 0 0 2px #22c55e,
            0 0 12px rgba(34, 197, 94, 0.5);
    }
    100% {
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    }
}

/* ==================================================
   Add Color Form
   ================================================== */

.color-manager-add-form {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    animation: slideDown 0.2s ease-out;
}

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

.add-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.add-form-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.add-form-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}

.add-form-close:hover {
    background: #fee2e2;
    color: #dc2626;
}

.add-form-body {
    padding: 16px;
}

.add-form-row {
    margin-bottom: 16px;
}

.add-form-row:last-child {
    margin-bottom: 0;
}

.add-form-row label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 6px;
}

.add-color-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    color: #1e293b;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.add-color-input::placeholder {
    color: #94a3b8;
}

.add-color-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.add-form-hint {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

.add-color-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.add-color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
}

.add-color-swatch:hover {
    transform: scale(1.05);
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.add-color-hex-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 14px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    color: #1e293b;
    text-transform: uppercase;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.add-color-hex-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.add-form-error {
    padding: 8px 12px;
    font-size: 13px;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    margin-top: 12px;
}

.add-form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.add-form-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.add-form-btn-cancel {
    color: #475569;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

.add-form-btn-cancel:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.add-form-btn-save {
    color: #ffffff;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border: none;
}

.add-form-btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
}

/* New color highlight animation */
.color-manager-color-item.is-new {
    animation: newColorHighlight 2s ease-out;
}

@keyframes newColorHighlight {
    0% {
        background: #dcfce7;
        box-shadow: inset 0 0 0 2px #22c55e;
    }
    100% {
        background: transparent;
        box-shadow: none;
    }
}

/* Dark mode for Add Color form */
body.dark .color-manager-add-form {
    background: #1e293b;
    border-color: #334155;
}

body.dark .add-form-header {
    background: #0f172a;
    border-color: #334155;
}

body.dark .add-form-title {
    color: #f1f5f9;
}

body.dark .add-form-close {
    color: #94a3b8;
}

body.dark .add-form-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

body.dark .add-form-row label {
    color: #94a3b8;
}

body.dark .add-color-input,
body.dark .add-color-hex-input {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

body.dark .add-color-input:focus,
body.dark .add-color-hex-input:focus {
    border-color: #3b82f6;
    background: #1e293b;
}

body.dark .add-color-swatch {
    border-color: #475569;
}

body.dark .add-color-swatch:hover {
    border-color: #60a5fa;
}

body.dark .add-form-hint {
    color: #64748b;
}

body.dark .add-form-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

body.dark .add-form-footer {
    background: #0f172a;
    border-color: #334155;
}

body.dark .add-form-btn-cancel {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark .add-form-btn-cancel:hover {
    background: #475569;
}

body.dark .color-manager-color-item.is-new {
    animation: newColorHighlightDark 2s ease-out;
}

@keyframes newColorHighlightDark {
    0% {
        background: rgba(34, 197, 94, 0.2);
        box-shadow: inset 0 0 0 2px #22c55e;
    }
    100% {
        background: transparent;
        box-shadow: none;
    }
}

/* =========================================
   Save As Dialog Styles
   ========================================= */

/* Overlay that dims the popup behind the dialog */
.color-manager-save-as-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 8px;
}

/* Dialog container */
.color-manager-save-as-dialog {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 360px;
    overflow: hidden;
    animation: saveAsDialogSlideIn 0.2s ease-out;
}

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

/* Dialog header */
.save-as-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.save-as-dialog-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.save-as-dialog-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.save-as-dialog-close:hover {
    opacity: 1;
}

/* Dialog body */
.save-as-dialog-body {
    padding: 16px;
}

.save-as-form-row {
    margin-bottom: 14px;
}

.save-as-form-row:last-of-type {
    margin-bottom: 8px;
}

.save-as-form-row label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}

.save-as-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #ffffff;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.save-as-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.save-as-input::placeholder {
    color: #9ca3af;
}

.save-as-hint {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
}

/* ID preview */
.save-as-id-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.save-as-id-value {
    font-family: monospace;
    font-size: 12px;
    color: #1f2937;
    font-weight: 500;
}

.save-as-id-hint {
    font-size: 10px;
    color: #9ca3af;
}

/* Error message */
.save-as-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 12px;
}

/* Dialog footer */
.save-as-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.save-as-btn-cancel {
    padding: 6px 12px;
}

.save-as-btn-save {
    padding: 6px 16px;
}

.save-as-btn-save.save-as-btn-overwrite {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #d97706;
}

.save-as-btn-save.save-as-btn-overwrite:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* =========================================
   Save As Dialog - Dark Mode
   ========================================= */

body.dark .color-manager-save-as-overlay {
    background: rgba(0, 0, 0, 0.7);
}

body.dark .color-manager-save-as-dialog {
    background: #1e293b;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body.dark .save-as-dialog-header {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

body.dark .save-as-form-row label {
    color: #e2e8f0;
}

body.dark .save-as-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .save-as-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

body.dark .save-as-input::placeholder {
    color: #64748b;
}

body.dark .save-as-hint {
    color: #64748b;
}

body.dark .save-as-id-preview {
    background: #0f172a;
    border-color: #334155;
}

body.dark .save-as-id-value {
    color: #e2e8f0;
}

body.dark .save-as-id-hint {
    color: #64748b;
}

body.dark .save-as-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

body.dark .save-as-dialog-footer {
    background: #0f172a;
    border-color: #334155;
}

body.dark .save-as-btn-save.save-as-btn-overwrite {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    border-color: #b45309;
}

body.dark .save-as-btn-save.save-as-btn-overwrite:hover {
    background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
}

/* Save to Themes Dialog - Dark Mode */
body.dark .save-to-themes-summary {
    color: #94a3b8;
}

body.dark .save-to-themes-select-controls a {
    color: #60a5fa;
}

body.dark .save-to-themes-theme-list {
    border-color: #334155;
    background: #0f172a;
}

body.dark .save-to-themes-theme-item {
    color: #e2e8f0;
    border-bottom-color: #1e293b;
}

body.dark .save-to-themes-theme-badge.active {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

body.dark .save-to-themes-theme-badge.default {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

/* ==================================================
   Delete Theme Confirmation Dialog
   ================================================== */

.color-manager-dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.color-manager-dialog {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.color-manager-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.color-manager-dialog-header h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.color-manager-dialog-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.color-manager-dialog-close:hover {
    opacity: 1;
}

.color-manager-dialog-body {
    padding: 20px 16px;
}

.color-manager-delete-theme-message {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #334155;
}

.color-manager-delete-theme-warning {
    margin: 0;
    font-size: 13px;
    color: #ef4444;
    font-weight: 500;
}

.color-manager-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

/* Dark mode - Delete Theme Dialog */
body.dark .color-manager-dialog-overlay {
    background: rgba(0, 0, 0, 0.7);
}

body.dark .color-manager-dialog {
    background: #1e293b;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body.dark .color-manager-dialog-header {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

body.dark .color-manager-delete-theme-message {
    color: #e2e8f0;
}

body.dark .color-manager-delete-theme-warning {
    color: #f87171;
}

body.dark .color-manager-dialog-footer {
    background: #0f172a;
    border-color: #334155;
}

/* ==================================================
   Unsaved Changes Confirmation Dialog (Phase 6 Task 4)
   ================================================== */

.color-manager-unsaved-dialog-header {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}

.color-manager-unsaved-message {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #334155;
}

.color-manager-unsaved-question {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

.color-manager-unsaved-dialog-footer {
    display: flex;
    gap: 8px;
}

.color-manager-unsaved-dialog-footer .color-manager-btn-danger {
    background: #ef4444;
    color: white;
}

.color-manager-unsaved-dialog-footer .color-manager-btn-danger:hover {
    background: #dc2626;
}

/* Dark mode - Unsaved Changes Dialog */
body.dark .color-manager-unsaved-dialog-header {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important;
}

body.dark .color-manager-unsaved-message {
    color: #e2e8f0;
}

body.dark .color-manager-unsaved-question {
    color: #94a3b8;
}

/* ==================================================
   Theme Details Panel (Phase 5 Task 12)
   ================================================== */

.color-manager-themes-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.color-manager-theme-details {
    flex-shrink: 0;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    max-height: 200px;
    overflow-y: auto;
}

.color-manager-theme-details-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #e2e8f0;
    border-bottom: 1px solid #cbd5e1;
}

.color-manager-theme-details-title {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-manager-theme-details-content {
    padding: 12px 16px;
}

.color-manager-theme-detail-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 8px;
}

.color-manager-theme-detail-row:last-child {
    margin-bottom: 0;
}

.color-manager-theme-detail-label {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    width: 80px;
    flex-shrink: 0;
    padding-top: 2px;
}

.color-manager-theme-detail-value {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.color-manager-theme-detail-text {
    font-size: 13px;
    color: #1e293b;
    word-break: break-word;
}

.color-manager-theme-detail-text:empty::after {
    content: "—";
    color: #94a3b8;
}

.color-manager-theme-detail-input {
    flex: 1;
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    outline: none;
    background: #ffffff;
    color: #1e293b;
}

.color-manager-theme-detail-input:focus {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.color-manager-theme-detail-textarea {
    flex: 1;
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    outline: none;
    resize: vertical;
    min-height: 60px;
    background: #ffffff;
    color: #1e293b;
    font-family: inherit;
}

.color-manager-theme-detail-textarea:focus {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.color-manager-theme-detail-description-row {
    flex-direction: column;
}

.color-manager-theme-detail-description-row .color-manager-theme-detail-label {
    margin-bottom: 4px;
    width: auto;
}

.color-manager-theme-detail-description-row .color-manager-theme-detail-value {
    width: 100%;
}

.color-manager-btn-icon-small {
    padding: 2px 6px;
    font-size: 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #64748b;
    transition: all 0.15s ease;
    line-height: 1;
}

.color-manager-btn-icon-small:hover {
    background: #e2e8f0;
    color: #3b82f6;
}

.color-manager-theme-readonly-notice {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    margin-top: 8px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    font-size: 12px;
    color: #92400e;
}

.color-manager-readonly-icon {
    font-size: 14px;
}

/* Adjust themes list when details panel is shown */
.color-manager-themes-container .color-manager-themes-list {
    max-height: none;
    flex: 1;
    min-height: 150px;
}

/* Dark mode - Theme Details Panel */
body.dark .color-manager-theme-details {
    background: #1e293b;
    border-color: #334155;
}

body.dark .color-manager-theme-details-header {
    background: #334155;
    border-color: #475569;
}

body.dark .color-manager-theme-details-title {
    color: #94a3b8;
}

body.dark .color-manager-theme-detail-text {
    color: #e2e8f0;
}

body.dark .color-manager-theme-detail-text:empty::after {
    color: #64748b;
}

body.dark .color-manager-theme-detail-input,
body.dark .color-manager-theme-detail-textarea {
    background: #0f172a;
    border-color: #3b82f6;
    color: #e2e8f0;
}

body.dark .color-manager-btn-icon-small {
    color: #94a3b8;
}

body.dark .color-manager-btn-icon-small:hover {
    background: #334155;
    color: #60a5fa;
}

body.dark .color-manager-theme-readonly-notice {
    background: rgba(254, 243, 199, 0.1);
    border-color: #b45309;
    color: #fcd34d;
}

/* ==================================================
   Accessibility Indicators and Panel
   ================================================== */

/* Accessibility icon in link button */
.color-manager-accessibility-icon {
    font-size: 14px;
    margin-right: 2px;
}

/* Accessibility warning indicator on color items */
.color-manager-accessibility-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
    flex-shrink: 0;
    cursor: help;
    transition: transform 0.15s ease;
}

.color-manager-accessibility-indicator:hover {
    transform: scale(1.15);
}

/* Accessibility level badges */
.color-manager-accessibility-indicator.level-aaa {
    background: #22c55e;
    color: #ffffff;
}

.color-manager-accessibility-indicator.level-aa {
    background: #3b82f6;
    color: #ffffff;
}

.color-manager-accessibility-indicator.level-aa-large {
    background: #f59e0b;
    color: #000000;
}

.color-manager-accessibility-indicator.level-fail {
    background: #ef4444;
    color: #ffffff;
}

/* Accessibility warning row (shown below color item) */
.color-manager-accessibility-warning {
    display: none;
    padding: 8px 12px 8px 36px;
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    font-size: 12px;
    color: #92400e;
    line-height: 1.4;
}

.color-manager-accessibility-warning.is-visible {
    display: block;
}

.color-manager-accessibility-warning.is-error {
    background: #fee2e2;
    border-left-color: #ef4444;
    color: #991b1b;
}

.color-manager-accessibility-warning .warning-title {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-manager-accessibility-warning .warning-title::before {
    content: '⚠';
    font-size: 14px;
}

.color-manager-accessibility-warning.is-error .warning-title::before {
    content: '❌';
}

.color-manager-accessibility-warning .warning-issues {
    margin-bottom: 4px;
}

.color-manager-accessibility-warning .warning-suggestion {
    font-style: italic;
    color: #b45309;
}

.color-manager-accessibility-warning.is-error .warning-suggestion {
    color: #b91c1c;
}

/* Accessibility Report Modal */
.color-manager-accessibility-report {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 380px;
    max-width: calc(100% - 40px);
    max-height: 80%;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.color-manager-accessibility-report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: #ffffff;
}

.color-manager-accessibility-report-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-manager-accessibility-report-header h3::before {
    content: '♿';
    font-size: 16px;
}

.color-manager-accessibility-report-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s ease;
}

.color-manager-accessibility-report-close:hover {
    opacity: 1;
}

.color-manager-accessibility-report-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.color-manager-accessibility-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.color-manager-accessibility-stat {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    background: #f8fafc;
}

.color-manager-accessibility-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.color-manager-accessibility-stat-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-manager-accessibility-stat.is-good .color-manager-accessibility-stat-value {
    color: #22c55e;
}

.color-manager-accessibility-stat.is-warning .color-manager-accessibility-stat-value {
    color: #f59e0b;
}

.color-manager-accessibility-stat.is-error .color-manager-accessibility-stat-value {
    color: #ef4444;
}

.color-manager-accessibility-section {
    margin-bottom: 16px;
}

.color-manager-accessibility-section:last-child {
    margin-bottom: 0;
}

.color-manager-accessibility-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-manager-accessibility-issue-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.color-manager-accessibility-issue {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: #fef3c7;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 12px;
}

.color-manager-accessibility-issue:last-child {
    margin-bottom: 0;
}

.color-manager-accessibility-issue.is-severe {
    background: #fee2e2;
}

.color-manager-accessibility-issue-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.color-manager-accessibility-issue-details {
    flex: 1;
    min-width: 0;
}

.color-manager-accessibility-issue-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
}

.color-manager-accessibility-issue-text {
    color: #64748b;
    line-height: 1.4;
}

.color-manager-accessibility-pair {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #fef3c7;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 12px;
}

.color-manager-accessibility-pair-swatches {
    display: flex;
    gap: 4px;
}

.color-manager-accessibility-pair-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.color-manager-accessibility-pair-details {
    flex: 1;
    min-width: 0;
}

.color-manager-accessibility-pair-names {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
}

.color-manager-accessibility-pair-types {
    color: #64748b;
    font-size: 11px;
}

.color-manager-accessibility-all-good {
    text-align: center;
    padding: 24px;
    color: #22c55e;
}

.color-manager-accessibility-all-good-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.color-manager-accessibility-all-good-text {
    font-size: 14px;
    font-weight: 600;
}

/* Color blindness simulation preview */
.color-manager-colorblind-preview {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #e2e8f0;
}

.color-manager-colorblind-preview-item {
    flex: 1;
    text-align: center;
}

.color-manager-colorblind-preview-swatch {
    width: 100%;
    height: 20px;
    border-radius: 3px;
    margin-bottom: 2px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.color-manager-colorblind-preview-label {
    font-size: 9px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Dark mode - Accessibility */
body.dark .color-manager-accessibility-warning {
    background: rgba(254, 243, 199, 0.1);
    color: #fcd34d;
}

body.dark .color-manager-accessibility-warning.is-error {
    background: rgba(254, 226, 226, 0.1);
    color: #fca5a5;
}

body.dark .color-manager-accessibility-warning .warning-suggestion {
    color: #fbbf24;
}

body.dark .color-manager-accessibility-warning.is-error .warning-suggestion {
    color: #f87171;
}

body.dark .color-manager-accessibility-report {
    background: #1e293b;
}

body.dark .color-manager-accessibility-report-header {
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
}

body.dark .color-manager-accessibility-stat {
    background: #0f172a;
}

body.dark .color-manager-accessibility-section-title {
    color: #94a3b8;
}

body.dark .color-manager-accessibility-issue {
    background: rgba(254, 243, 199, 0.1);
}

body.dark .color-manager-accessibility-issue.is-severe {
    background: rgba(254, 226, 226, 0.1);
}

body.dark .color-manager-accessibility-issue-name {
    color: #e2e8f0;
}

body.dark .color-manager-accessibility-pair {
    background: rgba(254, 243, 199, 0.1);
}

body.dark .color-manager-accessibility-pair-names {
    color: #e2e8f0;
}

body.dark .color-manager-accessibility-all-good {
    color: #4ade80;
}
