/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    line-height: 1;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

.btn--primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn--primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn--primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn--secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn--secondary:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--border-secondary);
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn--ghost:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.btn--icon {
    padding: var(--space-2);
    border-radius: var(--radius-md);
}

.btn--sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
}

.btn--lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
}

/* === INPUTS === */
.input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.input:hover {
    border-color: var(--border-secondary);
}

.input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input::placeholder {
    color: var(--text-tertiary);
}

/* === SELECT === */
.select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    padding-right: var(--space-10);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    transition: all var(--transition-fast);
}

.select:hover {
    border-color: var(--border-secondary);
}

.select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* === LABEL === */
.label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

/* === FORM GROUP === */
.form-group {
    margin-bottom: var(--space-4);
}

/* === COLOR PICKER === */
.color-picker {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.color-picker__swatch {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.color-picker__swatch:hover {
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.color-picker__swatch::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
    z-index: -1;
}

.color-picker__input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.color-picker__value {
    flex: 1;
}

.color-picker__hex {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-primary);
    text-transform: uppercase;
}

/* === COLOR PALETTE === */
.color-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
    gap: 6px;
}

.color-palette__item {
    aspect-ratio: 1;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    min-width: 28px;
    min-height: 28px;
}

.color-palette__item:hover {
    transform: scale(1.1);
    z-index: 1;
}

.color-palette__item.selected {
    border-color: var(--text-primary);
    box-shadow: var(--shadow-lg);
}

.color-palette__item.selected::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* === SLIDER === */
.slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-primary);
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* === TOGGLE === */
.toggle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.toggle__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle__switch {
    width: 40px;
    height: 22px;
    background: var(--border-secondary);
    border-radius: var(--radius-full);
    position: relative;
    transition: all var(--transition-base);
}

.toggle__switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: all var(--transition-spring);
    box-shadow: var(--shadow-sm);
}

.toggle__input:checked+.toggle__switch {
    background: var(--accent-primary);
}

.toggle__input:checked+.toggle__switch::after {
    transform: translateX(18px);
}

.toggle__label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* === CARD === */
.card {
    background: var(--surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    transition: all var(--transition-fast);
}

.card:hover {
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-md);
}

.card--selectable {
    cursor: pointer;
}

.card--selectable.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.card__title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.card__content {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* === PRESET CARD === */
.preset-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.preset-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.preset-card.selected {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.preset-card__colors {
    display: flex;
    gap: 2px;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
}

.preset-card__color {
    flex: 1;
}

.preset-card__name {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

/* === THEME TOGGLE === */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1);
    background: var(--surface-hover);
    border-radius: var(--radius-full);
}

.theme-toggle__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-toggle__btn.active {
    background: var(--surface);
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.theme-toggle__btn:hover:not(.active) {
    color: var(--text-primary);
}

/* === TABS === */
.tabs {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--surface-hover);
    border-radius: var(--radius-lg);
}

.tabs__btn {
    flex: 1;
    padding: var(--space-2) var(--space-4);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tabs__btn:hover:not(.active) {
    color: var(--text-primary);
}

.tabs__btn.active {
    background: var(--surface);
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

/* === TOOLTIP === */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-2) var(--space-3);
    background: var(--text-primary);
    color: var(--text-inverse);
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-fast);
}

.tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* === BADGE === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-full);
    background: var(--surface-active);
    color: var(--text-secondary);
}

.badge--primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

/* === DIVIDER === */
.divider {
    height: 1px;
    background: var(--border-primary);
    margin: var(--space-4) 0;
}

/* === EMPTY STATE === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12);
    text-align: center;
}

.empty-state__icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state__title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-state__description {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    max-width: 300px;
}

/* === MODAL === */
.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal__content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal__content h3 {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}

.modal__content textarea {
    width: 100%;
    min-height: 200px;
    padding: var(--space-4);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    resize: vertical;
    margin-bottom: var(--space-4);
}

.modal__content textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.modal__actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* === NOTIFICATION TOAST === */
.toast {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    padding: var(--space-4) var(--space-6);
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent-primary);
    animation: toastIn 0.3s ease;
    z-index: var(--z-tooltip);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast--success {
    border-left-color: var(--color-success);
}

.toast--error {
    border-left-color: var(--color-error);
}

/* === ICON ONLY BUTTON GROUP === */
.icon-btn-group {
    display: flex;
    gap: var(--space-1);
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.icon-btn.active {
    background: var(--accent-primary);
    color: white;
}

/* === COLOR CHIP (Brand Color, Neutral Palette) === */
.color-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-hover);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.color-chip:hover {
    border-color: var(--border-secondary);
    background: var(--surface-active);
}

.color-chip__dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.color-chip__chevron {
    width: 12px;
    height: 12px;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
}

.color-chip.open .color-chip__chevron {
    transform: rotate(180deg);
}

/* === PALETTE DROPDOWN === */
.palette-dropdown {
    position: relative;
}

.palette-dropdown__trigger {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-hover);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    width: fit-content;
}

.palette-dropdown__trigger:hover {
    border-color: var(--border-secondary);
}

.palette-dropdown__trigger.open {
    border-color: var(--accent-primary);
}

.palette-dropdown__preview {
    display: flex;
    gap: 2px;
}

.palette-dropdown__preview-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.palette-dropdown__icon {
    width: 16px;
    height: 16px;
    margin-right: var(--space-1);
}

.palette-dropdown__menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 0;
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.palette-dropdown__menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.palette-dropdown__section {
    padding: var(--space-2) 0;
}

.palette-dropdown__section:not(:last-child) {
    border-bottom: 1px solid var(--border-primary);
}

.palette-dropdown__section-title {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.palette-dropdown__option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.palette-dropdown__option:hover {
    background: var(--surface-hover);
}

.palette-dropdown__option.selected {
    background: rgba(99, 102, 241, 0.1);
}

.palette-dropdown__option-colors {
    display: flex;
    gap: 2px;
}

.palette-dropdown__option-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.palette-dropdown__option-name {
    flex: 1;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.palette-dropdown__option-check {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
    opacity: 0;
}

.palette-dropdown__option.selected .palette-dropdown__option-check {
    opacity: 1;
}

.palette-dropdown__add {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.palette-dropdown__add:hover {
    color: var(--accent-primary);
    background: var(--surface-hover);
}

.palette-dropdown__add svg {
    width: 14px;
    height: 14px;
}

/* === SEGMENTED TOGGLE (Light/Dark Appearance) === */
.segmented-toggle {
    display: inline-flex;
    padding: 2px;
    background: var(--surface-hover);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    gap: 2px;
}

.segmented-toggle__btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.segmented-toggle__btn:hover:not(.active) {
    color: var(--text-secondary);
}

.segmented-toggle__btn.active {
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.segmented-toggle__btn svg {
    width: 14px;
    height: 14px;
}

/* === STATE COLOR CHIPS === */
.state-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.state-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-hover);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.state-chip:hover {
    border-color: var(--border-secondary);
}

.state-chip__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.state-chip__chevron {
    width: 12px;
    height: 12px;
    color: var(--text-tertiary);
    margin-left: var(--space-1);
}

/* === ACCORDION === */
.accordion {
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.accordion__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.accordion__header:hover {
    background: var(--surface-hover);
}

.accordion__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
}

.accordion__chevron {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
}

.accordion.open .accordion__chevron {
    transform: rotate(90deg);
}

.accordion__content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.accordion.open .accordion__content {
    max-height: 500px;
}

.accordion__body {
    padding: var(--space-4);
    border-top: 1px solid var(--border-primary);
}

/* === FORM ROW (Label + Control side by side) === */
.form-row {
    margin-bottom: var(--space-4);
}

.form-row__label {
    display: block;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}

/* === ADD BUTTON === */
.add-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 1px dashed var(--border-secondary);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.add-btn svg {
    width: 14px;
    height: 14px;
}