/**
 * Kramar — Checkout Field Builder Styles
 *
 * 3-panel drag-and-drop checkout field editor.
 * Palette | Canvas (form preview) | Settings
 *
 * @package Kramar
 * @since   1.0.0
 */

/* ==========================================================================
   Design Tokens
   ========================================================================== */

:root {
    --kramar-fb-primary:       #7f54b3;
    --kramar-fb-primary-hover: #6b4599;
    --kramar-fb-primary-light: #f3eefb;
    --kramar-fb-bg:            #f0f0f1;
    --kramar-fb-surface:       #fff;
    --kramar-fb-surface-alt:   #f9fafb;
    --kramar-fb-border:        #dcdcde;
    --kramar-fb-border-light:  #f0f0f1;
    --kramar-fb-text:          #1d2327;
    --kramar-fb-text-muted:    #787c82;
    --kramar-fb-text-light:    #a7aaad;
    --kramar-fb-danger:        #d63638;
    --kramar-fb-danger-light:  #fef1f1;
    --kramar-fb-success:       #00a32a;
    --kramar-fb-radius:        4px;
    --kramar-fb-radius-sm:     3px;
    --kramar-fb-shadow:        0 1px 3px rgba(0,0,0,.08);
    --kramar-fb-shadow-md:     0 2px 8px rgba(0,0,0,.10);
    --kramar-fb-transition:    150ms ease;
    --kramar-fb-font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Dark mode: remap the design tokens so ALL variable-driven elements (palette
   labels/icons, toggle labels, badges, settings icon, etc.) theme correctly.
   Explicit `.dark-mode .kramar-fb-*` rules further down still win where present.
   Saturated tokens (primary/danger/success) are intentionally kept. */
body.dark-mode {
    --kramar-fb-primary-light: rgba(127,84,179,.18);
    --kramar-fb-bg:            #1a1e26;
    --kramar-fb-surface:       #1d2327;
    --kramar-fb-surface-alt:   #2c3338;
    --kramar-fb-border:        #3c434a;
    --kramar-fb-border-light:  #3c434a;
    --kramar-fb-text:          #eceff4;
    --kramar-fb-text-muted:    #a7aaad;
    --kramar-fb-text-light:    #8b9198;
    --kramar-fb-danger-light:  #2b1d1d;
    --kramar-fb-shadow:        0 1px 3px rgba(0,0,0,.4);
    --kramar-fb-shadow-md:     0 2px 8px rgba(0,0,0,.5);
}

/* ==========================================================================
   Wrap
   ========================================================================== */

.kramar-field-builder-wrap {
    margin-right: 0;
    padding-bottom: 0;
}

/* ==========================================================================
   Toolbar
   ========================================================================== */

.kramar-fb-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--kramar-fb-surface);
    border: 1px solid var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius);
    box-shadow: var(--kramar-fb-shadow);
    margin-bottom: 16px;
    position: sticky;
    top: 32px;
    z-index: 200;
}

.kramar-fb-toolbar__back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--kramar-fb-radius-sm);
    color: var(--kramar-fb-text-muted);
    text-decoration: none;
    transition: background var(--kramar-fb-transition), color var(--kramar-fb-transition);
    flex-shrink: 0;
    font-size: 18px;
    line-height: 1;
}
.kramar-fb-toolbar__back:hover {
    background: var(--kramar-fb-surface-alt);
    color: var(--kramar-fb-text);
}

.kramar-fb-toolbar__title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--kramar-fb-text);
    margin: 0;
    padding: 0;
    line-height: 1.4;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kramar-fb-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Export link + Import form sit side by side (without this rule the block-level
   <form> drops below the inline Export <a>). */
.kramar-fb-toolbar__io {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.kramar-fb-toolbar__io .kramar-fb-import-form {
    margin: 0;
    display: inline-flex;
}

.kramar-fb-field-count {
    font-size: 12px;
    color: var(--kramar-fb-text-muted);
}

/* Save status */
.kramar-fb-save-status {
    font-size: 12px;
    color: var(--kramar-fb-text-muted);
    transition: color var(--kramar-fb-transition);
}
.kramar-fb-save-status.is-saved  { color: var(--kramar-fb-success); }
.kramar-fb-save-status.is-error  { color: var(--kramar-fb-danger); }
.kramar-fb-save-status.is-saving { color: var(--kramar-fb-primary); }

/* Toolbar buttons */
.kramar-fb-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--kramar-fb-radius-sm);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--kramar-fb-font);
    cursor: pointer;
    transition: all var(--kramar-fb-transition);
    text-decoration: none;
    border: 1px solid;
    line-height: 1.4;
    white-space: nowrap;
}
.kramar-fb-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}
.kramar-fb-btn--ghost,
.kramar-fb-btn--secondary {
    background: none;
    border-color: var(--kramar-fb-border);
    color: var(--kramar-fb-text-muted);
}
.kramar-fb-btn--ghost:hover,
.kramar-fb-btn--secondary:hover {
    border-color: #c3c4c7;
    color: var(--kramar-fb-text);
    background: var(--kramar-fb-surface-alt);
}
.kramar-fb-btn--primary {
    background: var(--kramar-fb-primary);
    border-color: var(--kramar-fb-primary);
    color: #fff;
}
.kramar-fb-btn--primary:hover {
    background: var(--kramar-fb-primary-hover);
    border-color: var(--kramar-fb-primary-hover);
    color: #fff;
}
.kramar-fb-btn--primary:disabled,
.kramar-fb-btn--ghost:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Hide WP admin notices on builder page */
body.admin_page_kramar-checkout-fields .notice,
body.admin_page_kramar-checkout-fields .updated,
body.admin_page_kramar-checkout-fields .error,
body:has(.kramar-field-builder-wrap) .notice,
body:has(.kramar-field-builder-wrap) .updated { display: none !important; }

/* ==========================================================================
   3-Panel Layout
   ========================================================================== */

.kramar-fb-builder {
    display: grid;
    grid-template-columns: 240px 1fr 340px;
    gap: 16px;
    align-items: start;
}

/* ==========================================================================
   Left Panel — Field Palette
   ========================================================================== */

.kramar-fb-palette {
    background: var(--kramar-fb-surface);
    border: 1px solid var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius);
    box-shadow: var(--kramar-fb-shadow);
    overflow: hidden;
    position: sticky;
    top: 110px;
    max-height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
    border-left: 3px solid var(--kramar-fb-primary);
}

.kramar-fb-palette__header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--kramar-fb-border-light);
    background: var(--kramar-fb-surface-alt);
    flex-shrink: 0;
}

.kramar-fb-palette__header h3 {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--kramar-fb-text-muted);
}

.kramar-fb-palette__search {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius-sm);
    font-size: 12px;
    font-family: var(--kramar-fb-font);
    color: var(--kramar-fb-text);
    background: var(--kramar-fb-surface);
    outline: none;
    box-sizing: border-box;
    transition: border-color var(--kramar-fb-transition), box-shadow var(--kramar-fb-transition);
}
.kramar-fb-palette__search:focus {
    border-color: var(--kramar-fb-primary);
    box-shadow: 0 0 0 2px rgba(127,84,179,.15);
}
.kramar-fb-palette__search::placeholder {
    color: var(--kramar-fb-text-light);
}

.kramar-fb-palette__body {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-sizing: border-box;
}

.kramar-fb-palette-group {
    padding: 10px 4px 4px;
}
.kramar-fb-palette-group:first-child { padding-top: 2px; }

.kramar-fb-palette-group__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--kramar-fb-text-light);
    margin: 0 0 4px;
    padding: 0;
}

.kramar-fb-palette-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: var(--kramar-fb-radius-sm);
    cursor: grab;
    font-size: 12px;
    font-weight: 500;
    color: var(--kramar-fb-text);
    background: transparent;
    transition: all var(--kramar-fb-transition);
    user-select: none;
    width: 100%;
    text-align: left;
    font-family: var(--kramar-fb-font);
}
.kramar-fb-palette-item:hover {
    background: var(--kramar-fb-primary-light);
    border-color: rgba(127,84,179,.3);
    color: var(--kramar-fb-primary);
}
.kramar-fb-palette-item:active { cursor: grabbing; }

.kramar-fb-palette-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--kramar-fb-surface-alt);
    border: 1px solid var(--kramar-fb-border-light);
    border-radius: var(--kramar-fb-radius-sm);
    font-size: 14px;
    color: var(--kramar-fb-text-muted);
    flex-shrink: 0;
    transition: all var(--kramar-fb-transition);
}
.kramar-fb-palette-icon.dashicons::before {
    font-size: 14px;
    width: 14px;
    height: 14px;
}
.kramar-fb-palette-item:hover .kramar-fb-palette-icon {
    background: #fff;
    border-color: rgba(127,84,179,.4);
    color: var(--kramar-fb-primary);
}

.kramar-fb-palette-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kramar-fb-palette-item--hidden {
    display: none;
}

/* ==========================================================================
   Center Panel — Canvas
   ========================================================================== */

.kramar-fb-canvas {
    background: var(--kramar-fb-surface);
    border: 1px solid var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius);
    box-shadow: var(--kramar-fb-shadow);
    padding: 20px;
}

/* Section tabs */
.kramar-fb-canvas-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--kramar-fb-border);
    margin-bottom: 0;
}

.kramar-fb-canvas-tab {
    padding: 10px 16px;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--kramar-fb-text-muted);
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--kramar-fb-font);
    transition: all var(--kramar-fb-transition);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -1px;
}
.kramar-fb-canvas-tab:hover {
    color: var(--kramar-fb-text);
}
.kramar-fb-canvas-tab--active {
    border-bottom-color: var(--kramar-fb-primary);
    color: var(--kramar-fb-primary);
}

.kramar-fb-canvas-tab__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--kramar-fb-surface-alt);
    border: 1px solid var(--kramar-fb-border);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    color: var(--kramar-fb-text-muted);
    line-height: 1;
}
.kramar-fb-canvas-tab--active .kramar-fb-canvas-tab__count {
    background: var(--kramar-fb-primary-light);
    border-color: rgba(127,84,179,.3);
    color: var(--kramar-fb-primary);
}

.kramar-fb-canvas-body {
    padding-top: 16px;
}

.kramar-fb-form-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Empty state */
.kramar-fb-canvas__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    gap: 10px;
    border: 2px dashed var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius);
    background: var(--kramar-fb-surface);
    min-height: 200px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color var(--kramar-fb-transition), background var(--kramar-fb-transition);
}
.kramar-fb-canvas__empty .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: var(--kramar-fb-text-light);
}
.kramar-fb-canvas__empty p {
    margin: 0;
    font-size: 13px;
    color: var(--kramar-fb-text-muted);
}
.kramar-fb-canvas__empty.is-drag-over,
.kramar-fb-form-preview.is-drag-over {
    border-color: var(--kramar-fb-primary);
    background: var(--kramar-fb-primary-light);
}

/* ==========================================================================
   Form Field Preview Cards
   ========================================================================== */

.kramar-fb-form-field {
    position: relative;
    border: 2px solid transparent;
    border-radius: var(--kramar-fb-radius);
    padding: 12px;
    cursor: pointer;
    transition: all var(--kramar-fb-transition);
    background: var(--kramar-fb-surface);
    box-sizing: border-box;
}

.kramar-fb-form-field--wide  { width: 100%; }
.kramar-fb-form-field--first { width: calc(50% - 6px); }
.kramar-fb-form-field--last  { width: calc(50% - 6px); }

.kramar-fb-form-field:hover {
    border-color: #c3c4c7;
    box-shadow: var(--kramar-fb-shadow);
}
.kramar-fb-form-field--selected {
    border-color: var(--kramar-fb-primary) !important;
    box-shadow: 0 0 0 1px var(--kramar-fb-primary);
}
.kramar-fb-form-field--disabled {
    opacity: 0.45;
}

/* Action bar */
.kramar-fb-form-field__actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--kramar-fb-transition);
    z-index: 10;
}
.kramar-fb-form-field:hover .kramar-fb-form-field__actions,
.kramar-fb-form-field--selected .kramar-fb-form-field__actions {
    opacity: 1;
}

.kramar-fb-form-field__handle,
.kramar-fb-form-field__delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--kramar-fb-surface);
    border: 1px solid var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--kramar-fb-text-muted);
    transition: all var(--kramar-fb-transition);
}
.kramar-fb-form-field__handle {
    cursor: grab;
}
.kramar-fb-form-field__handle:active { cursor: grabbing; }
.kramar-fb-form-field__delete:hover {
    color: var(--kramar-fb-danger);
    border-color: var(--kramar-fb-danger);
    background: var(--kramar-fb-danger-light);
}
.kramar-fb-form-field__handle .dashicons,
.kramar-fb-form-field__delete .dashicons {
    font-size: 13px;
    width: 13px;
    height: 13px;
}

/* Label row */
.kramar-fb-form-field__label-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.kramar-fb-form-field__label-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--kramar-fb-text);
}

.kramar-fb-form-field__required {
    font-size: 14px;
    font-weight: 700;
    color: var(--kramar-fb-danger);
    flex-shrink: 0;
    line-height: 1;
}

.kramar-fb-form-field__custom {
    font-size: 10px;
    font-weight: 600;
    color: var(--kramar-fb-text-light);
    margin-left: auto;
    flex-shrink: 0;
}

/* Badges — used in settings panel header */
.kramar-fb-badge {
    display: inline-block;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 10px;
    letter-spacing: 0.02em;
}
.kramar-fb-badge--custom {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}
.kramar-fb-badge--default {
    background: var(--kramar-fb-primary-light);
    border: 1px solid rgba(127,84,179,.3);
    color: var(--kramar-fb-primary);
}

/* Preview elements */
.kramar-fb-form-field__preview {
    pointer-events: none;
}

.kramar-fb-preview-input,
.kramar-fb-preview-select {
    display: block;
    width: 100%;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius-sm);
    font-size: 13px;
    font-family: var(--kramar-fb-font);
    color: var(--kramar-fb-text-muted);
    background: var(--kramar-fb-surface-alt);
    box-sizing: border-box;
    appearance: none;
}

.kramar-fb-preview-textarea {
    display: block;
    width: 100%;
    min-height: 60px;
    padding: 6px 8px;
    border: 1px solid var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius-sm);
    font-size: 13px;
    font-family: var(--kramar-fb-font);
    color: var(--kramar-fb-text-muted);
    background: var(--kramar-fb-surface-alt);
    box-sizing: border-box;
    resize: none;
}

.kramar-fb-preview-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--kramar-fb-text-muted);
}

.kramar-fb-preview-radio {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 13px;
    color: var(--kramar-fb-text-muted);
}
.kramar-fb-preview-radio label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: default;
}
.kramar-fb-preview-placeholder {
    font-size: 12px;
    color: var(--kramar-fb-text-light);
    font-style: italic;
}

.kramar-fb-preview-heading {
    font-size: 16px;
    font-weight: 700;
    color: var(--kramar-fb-text);
    margin: 0;
    line-height: 1.3;
}

.kramar-fb-preview-paragraph {
    font-size: 13px;
    color: var(--kramar-fb-text-muted);
    margin: 0;
    line-height: 1.5;
}

.kramar-fb-hidden-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    background: var(--kramar-fb-surface-alt);
    border: 1px solid var(--kramar-fb-border);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    color: var(--kramar-fb-text-muted);
}

/* ==========================================================================
   Right Panel — Settings
   ========================================================================== */

.kramar-fb-settings {
    background: var(--kramar-fb-surface);
    border: 1px solid var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius);
    box-shadow: var(--kramar-fb-shadow);
    overflow: hidden;
    position: sticky;
    top: 110px;
    max-height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
}

.kramar-fb-settings__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: var(--kramar-fb-text-light);
    text-align: center;
    gap: 8px;
    flex: 1;
}
.kramar-fb-settings__empty .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
    opacity: 0.2;
}
.kramar-fb-settings__empty p {
    margin: 0;
    font-size: 13px;
    color: var(--kramar-fb-text-muted);
}

.kramar-fb-settings__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--kramar-fb-border-light);
    background: var(--kramar-fb-surface-alt);
    flex-shrink: 0;
}

.kramar-fb-settings__icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--kramar-fb-primary-light);
    color: var(--kramar-fb-primary);
    border-radius: var(--kramar-fb-radius-sm);
    font-size: 16px;
    flex-shrink: 0;
}
.kramar-fb-settings__icon .dashicons { font-size: 16px; width: 16px; height: 16px; }

.kramar-fb-settings__heading {
    flex: 1;
    min-width: 0;
}
.kramar-fb-settings__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--kramar-fb-text);
    line-height: 1.3;
}
.kramar-fb-settings__subtitle {
    font-size: 11px;
    color: var(--kramar-fb-text-muted);
    margin-top: 1px;
}

.kramar-fb-settings__body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.kramar-fb-settings-form {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ==========================================================================
   Settings Form Fields
   ========================================================================== */

.kramar-fb-setting {
    margin-bottom: 14px;
}
.kramar-fb-setting:last-child { margin-bottom: 0; }

.kramar-fb-setting__label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--kramar-fb-text);
    line-height: 1.4;
}

.kramar-fb-setting__input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--kramar-fb-border);
    border-radius: var(--kramar-fb-radius-sm);
    font-size: 13px;
    font-family: var(--kramar-fb-font);
    color: var(--kramar-fb-text);
    background: var(--kramar-fb-surface);
    outline: none;
    box-sizing: border-box;
    transition: border-color var(--kramar-fb-transition), box-shadow var(--kramar-fb-transition);
}
.kramar-fb-setting__input:focus {
    border-color: var(--kramar-fb-primary);
    box-shadow: 0 0 0 2px rgba(127,84,179,.15);
}
.kramar-fb-setting__input:disabled {
    background: var(--kramar-fb-surface-alt);
    color: var(--kramar-fb-text-muted);
    cursor: not-allowed;
}

/* Keep WP core's <select> chevron from tiling: the shorthand `background`
   above resets background-repeat to `repeat`. See audit finding G17. */
select.kramar-fb-setting__input {
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
}

textarea.kramar-fb-setting__input {
    resize: vertical;
    min-height: 72px;
    line-height: 1.5;
}

.kramar-fb-setting__input--small {
    width: 80px;
}

.kramar-fb-setting__input--key {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 12px;
}

.kramar-fb-setting__group-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--kramar-fb-text-light);
    margin-bottom: 8px;
    margin-top: 4px;
}

.kramar-fb-settings__footer {
    padding: 12px 16px;
    border-top: 1px solid var(--kramar-fb-border-light);
    flex-shrink: 0;
}

@keyframes kramarFbSettingsPanelIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.kramar-fb-settings--animate {
    animation: kramarFbSettingsPanelIn 180ms ease;
}

.kramar-fb-setting__hint {
    font-size: 11px;
    color: var(--kramar-fb-text-muted);
    margin-top: 3px;
    line-height: 1.4;
}

.kramar-fb-setting__divider {
    height: 1px;
    background: var(--kramar-fb-border-light);
    margin: 12px 0;
}

/* CSS-only toggle switches */
.kramar-fb-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 6px;
}
.kramar-fb-toggle-row:last-child { margin-bottom: 0; }
.kramar-fb-toggle-row input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.kramar-fb-toggle-track {
    display: block;
    position: relative;
    width: 36px;
    min-width: 36px;
    height: 20px;
    border-radius: 10px;
    background: #c3c4c7;
    transition: background var(--kramar-fb-transition);
    flex-shrink: 0;
    cursor: pointer;
}
.kramar-fb-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
    transition: transform var(--kramar-fb-transition);
}
.kramar-fb-toggle-row input[type="checkbox"]:checked + .kramar-fb-toggle-track {
    background: var(--kramar-fb-primary);
}
.kramar-fb-toggle-row input[type="checkbox"]:checked + .kramar-fb-toggle-track .kramar-fb-toggle-thumb {
    transform: translateX(16px);
}
.kramar-fb-toggle-row > span:last-child {
    font-size: 13px;
    color: var(--kramar-fb-text);
    cursor: pointer;
    user-select: none;
}

/* Width control */
.kramar-fb-width-control {
    display: flex;
    flex-direction: row;
    gap: 0;
}
.kramar-fb-width-btn {
    flex: 1;
    height: 34px;
    border: 1px solid var(--kramar-fb-border);
    border-radius: 0;
    background: var(--kramar-fb-surface);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--kramar-fb-font);
    color: var(--kramar-fb-text-muted);
    cursor: pointer;
    transition: all var(--kramar-fb-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: -1px;
}
.kramar-fb-width-btn:first-child { border-radius: var(--kramar-fb-radius-sm) 0 0 var(--kramar-fb-radius-sm); }
.kramar-fb-width-btn:last-child  { border-radius: 0 var(--kramar-fb-radius-sm) var(--kramar-fb-radius-sm) 0; margin-right: 0; }
.kramar-fb-width-btn:hover {
    border-color: #c3c4c7;
    color: var(--kramar-fb-text);
    z-index: 1;
}
.kramar-fb-width-btn--active {
    border-color: var(--kramar-fb-primary) !important;
    background: var(--kramar-fb-primary-light);
    color: var(--kramar-fb-primary);
    z-index: 2;
}

/* Collapsible sections */
.kramar-fb-collapsible__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 14px;
    background: var(--kramar-fb-surface-alt);
    border-top: 1px solid var(--kramar-fb-border-light);
    font-size: 12px;
    font-weight: 600;
    color: var(--kramar-fb-text-muted);
    user-select: none;
    transition: color var(--kramar-fb-transition);
}
.kramar-fb-collapsible__trigger:hover { color: var(--kramar-fb-text); }
.kramar-fb-collapsible__trigger .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    transition: transform var(--kramar-fb-transition);
}
.kramar-fb-collapsible--open .kramar-fb-collapsible__trigger .dashicons {
    transform: rotate(180deg);
}
.kramar-fb-collapsible__body {
    display: none;
    padding: 12px 14px;
    border-top: 1px solid var(--kramar-fb-border-light);
}
.kramar-fb-collapsible--open .kramar-fb-collapsible__body { display: block; }

/* Delete button */
.kramar-fb-btn-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 6px 12px;
    background: none;
    border: 1px solid var(--kramar-fb-danger);
    border-radius: var(--kramar-fb-radius-sm);
    color: var(--kramar-fb-danger);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--kramar-fb-font);
    cursor: pointer;
    transition: all var(--kramar-fb-transition);
}
.kramar-fb-btn-delete:hover {
    background: var(--kramar-fb-danger);
    color: #fff;
}
.kramar-fb-btn-delete:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================================================
   Drag and Drop
   ========================================================================== */

.kramar-fb-drop-placeholder {
    height: 80px;
    background: var(--kramar-fb-primary-light);
    border: 2px dashed rgba(127,84,179,.5);
    border-radius: var(--kramar-fb-radius-sm);
    animation: kramarFbFadeIn 120ms ease;
    width: 100%;
    box-sizing: border-box;
}

.kramar-fb-form-field--dragging { opacity: 0.3; }

@keyframes kramarFbSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.kramar-fb-form-field--new {
    animation: kramarFbSlideIn 200ms ease;
}

@keyframes kramarFbFadeOut {
    from { opacity: 1; transform: scaleY(1); }
    to   { opacity: 0; transform: scaleY(0); transform-origin: top; }
}
.kramar-fb-form-field--removing {
    animation: kramarFbFadeOut 180ms ease forwards;
}

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

.kramar-fb-notice-toast {
    position: fixed;
    bottom: 40px;
    left: 0;
    right: 0;
    width: fit-content;
    margin: 0 auto;
    z-index: 99999;
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(0,0,0,.2);
    animation: kramarFbFadeUp 200ms ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.kramar-fb-notice-toast--success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: var(--kramar-fb-success);
}
.kramar-fb-notice-toast--error {
    background: var(--kramar-fb-danger-light);
    border: 1px solid var(--kramar-fb-danger);
    color: var(--kramar-fb-danger);
}
.kramar-fb-notice-toast--fade {
    opacity: 0;
    transition: opacity 300ms ease;
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

/* ==========================================================================
   Responsive — 2-column at <=1200px, single-column at <=782px
   ========================================================================== */

/* 2-column: palette + canvas side by side, settings below canvas.
   Keeps the builder usable at 1024px-1200px (palette + canvas visible
   together without scrolling between them). Mirrors email-builder strategy. */
@media (max-width: 1200px) {
    .kramar-fb-builder {
        grid-template-columns: 220px 1fr;
        grid-template-rows: auto auto;
    }
    .kramar-fb-palette {
        grid-row: 1 / 3;
    }
    .kramar-fb-settings {
        position: static;
        max-height: none;
    }
    .kramar-fb-toolbar {
        position: static;
        flex-wrap: wrap;
    }
}

/* Single-column: stack everything for very narrow viewports. */
@media (max-width: 782px) {
    .kramar-fb-builder {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    .kramar-fb-palette,
    .kramar-fb-canvas,
    .kramar-fb-settings {
        min-width: 0;
    }
    .kramar-fb-palette {
        grid-row: auto;
        position: static;
        max-height: none;
        border-left: none;
        border-top: 3px solid var(--kramar-fb-primary);
    }
    .kramar-fb-palette__body {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }
    .kramar-fb-palette-group {
        width: 100%;
        padding: 8px 4px 2px;
    }
    .kramar-fb-palette-item {
        width: auto;
        flex: 0 0 auto;
    }
    .kramar-fb-form-field--first,
    .kramar-fb-form-field--last {
        width: 100%;
    }
    .kramar-fb-settings {
        position: static;
        max-height: none;
    }
    .kramar-fb-toolbar {
        position: static;
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .kramar-fb-toolbar {
        gap: 8px;
        padding: 8px 10px;
    }
    .kramar-fb-toolbar__title {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
    .kramar-fb-toolbar__actions {
        flex-wrap: wrap;
        width: 100%;
    }
    .kramar-fb-palette {
        min-width: 0;
    }
    .kramar-fb-palette__header {
        padding: 8px 10px;
        box-sizing: border-box;
    }
    .kramar-fb-palette__search {
        max-width: 100%;
    }
    .kramar-fb-canvas {
        padding: 12px;
    }
    .kramar-fb-canvas-tabs {
        flex-wrap: wrap;
    }
    .kramar-fb-canvas-tab {
        padding: 8px 10px;
        font-size: 12px;
    }
}

/* ==========================================================================
   Dark Mode (.dark-mode on <body>)
   ========================================================================== */

.dark-mode .kramar-fb-toolbar,
.dark-mode .kramar-fb-palette,
.dark-mode .kramar-fb-settings,
.dark-mode .kramar-fb-canvas {
    background: #1d2327;
    border-color: #3c434a;
}

.dark-mode .kramar-fb-palette__header,
.dark-mode .kramar-fb-settings__header,
.dark-mode .kramar-fb-collapsible__trigger {
    background: #2c3338;
    border-color: #3c434a;
}

.dark-mode .kramar-fb-toolbar__title,
.dark-mode .kramar-fb-settings__title,
.dark-mode .kramar-fb-setting__label,
.dark-mode .kramar-fb-form-field__label-text {
    color: #f0f0f1;
}

.dark-mode .kramar-fb-settings__subtitle,
.dark-mode .kramar-fb-setting__hint {
    color: #a7aaad;
}

.dark-mode .kramar-fb-setting__input {
    background: #2c3338;
    border-color: #3c434a;
    color: #f0f0f1;
}
.dark-mode .kramar-fb-setting__input:focus {
    border-color: var(--kramar-fb-primary);
}

.dark-mode .kramar-fb-form-field {
    background: #23282d;
    border-color: transparent;
}
.dark-mode .kramar-fb-form-field:hover {
    border-color: #3c434a;
}
.dark-mode .kramar-fb-form-field--selected {
    border-color: var(--kramar-fb-primary) !important;
}

.dark-mode .kramar-fb-form-field__handle,
.dark-mode .kramar-fb-form-field__delete {
    background: #2c3338;
    border-color: #3c434a;
    color: #a7aaad;
}

.dark-mode .kramar-fb-canvas__empty {
    background: #1d2327;
    border-color: #3c434a;
}

.dark-mode .kramar-fb-canvas-tabs {
    border-color: #3c434a;
}

/* DARK-CF-1: tab count badges stayed light (surface-alt / primary-light) on the dark tab bar */
.dark-mode .kramar-fb-canvas-tab__count {
    background: #2c3338;
    border-color: #3c434a;
    color: #a7aaad;
}
.dark-mode .kramar-fb-canvas-tab--active .kramar-fb-canvas-tab__count {
    background: #33384a;
    border-color: rgba(127,84,179,.5);
    color: #c9b6e8;
}

.dark-mode .kramar-fb-palette__search {
    background: #2c3338;
    border-color: #3c434a;
    color: #f0f0f1;
}

.dark-mode .kramar-fb-settings-form {
    background: #1d2327;
}

.dark-mode .kramar-fb-preview-input,
.dark-mode .kramar-fb-preview-select,
.dark-mode .kramar-fb-preview-textarea {
    background: #2c3338;
    border-color: #3c434a;
    color: #a7aaad;
}

.dark-mode .kramar-fb-toggle-track {
    background: #50575e;
}

.dark-mode .kramar-fb-width-btn {
    background: #2c3338;
    border-color: #3c434a;
    color: #a7aaad;
}
.dark-mode .kramar-fb-width-btn--active {
    background: rgba(127,84,179,.2);
    border-color: var(--kramar-fb-primary) !important;
    color: #c9a6f5;
}
