/**
 * Kramar — Email Builder Styles
 *
 * 3-panel drag-and-drop email template editor.
 * Palette | Canvas (email preview) | Settings
 *
 * @package Kramar
 * @since   1.0.0
 */

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

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

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

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

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

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

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

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

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

/* Status badge */
.kramar-eb-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    border: 1px solid;
}
.kramar-eb-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.kramar-eb-status--enabled {
    background: #f0fdf4;
    color: var(--kramar-eb-success);
    border-color: #bbf7d0;
}
.kramar-eb-status--enabled::before { background: var(--kramar-eb-success); }
.kramar-eb-status--disabled {
    background: var(--kramar-eb-surface-alt);
    color: var(--kramar-eb-text-muted);
    border-color: var(--kramar-eb-border);
}
.kramar-eb-status--disabled::before { background: var(--kramar-eb-text-light); }

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

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

/* Toast notice (appended to toolbar by JS) */
.kramar-eb-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: kramarEbFadeUp 200ms ease;
    background: var(--kramar-eb-surface);
    border: 1px solid var(--kramar-eb-border);
    color: var(--kramar-eb-text);
    display: flex;
    align-items: center;
    gap: 8px;
}
@keyframes kramarEbFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hide WP admin notices on builder page */
body.toplevel_page_kramar-email-builder .notice,
body.toplevel_page_kramar-email-builder .updated,
body.toplevel_page_kramar-email-builder .error,
body.admin_page_kramar-email-builder .notice,
body.admin_page_kramar-email-builder .updated,
body.admin_page_kramar-email-builder .error,
.kramar-eb-wrap ~ .notice,
.kramar-eb-wrap ~ .updated,
.kramar-eb-wrap ~ .error,
#wpbody-content > .notice,
#wpbody-content > .updated,
#wpbody-content > .error {
    display: none !important;
}
/* Only hide when builder CSS is loaded (specificity via body class) */
body:has(.kramar-eb-wrap) .notice,
body:has(.kramar-eb-wrap) .updated {
    display: none !important;
}
.kramar-eb-notice-toast--success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: var(--kramar-eb-success);
}
.kramar-eb-notice-toast--error {
    background: var(--kramar-eb-danger-light);
    border-color: var(--kramar-eb-danger);
    color: var(--kramar-eb-danger);
}

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

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

/* ==========================================================================
   Left Panel — Block Palette
   ========================================================================== */

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

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

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

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

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

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

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

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

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

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

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

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

.kramar-eb-canvas {
    min-height: 600px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Subject line row — actual class used in PHP */
.kramar-eb-canvas__subject {
    background: var(--kramar-eb-surface);
    border: 1px solid var(--kramar-eb-border);
    border-radius: var(--kramar-eb-radius);
    padding: 10px 14px;
    box-shadow: var(--kramar-eb-shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.kramar-eb-canvas__subject label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--kramar-eb-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.kramar-eb-canvas__subject-input,
.kramar-eb-canvas__subject input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 13px;
    color: var(--kramar-eb-text);
    font-family: var(--kramar-eb-font);
    background: transparent;
    padding: 0;
}
.kramar-eb-canvas__subject-input::placeholder,
.kramar-eb-canvas__subject input::placeholder {
    color: var(--kramar-eb-text-light);
}

/* Email wrapper — the full email preview container */
.kramar-eb-canvas__email-wrapper {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.kramar-eb-canvas__email-header {
    text-align: center;
    padding: 8px 0 20px;
}

.kramar-eb-canvas__email-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e4e4e7;
    overflow: hidden;
}

.kramar-eb-canvas__email-container {
    min-height: 200px;
    padding: 32px 40px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #525252;
}

.kramar-eb-canvas__email-footer {
    text-align: center;
    padding: 20px 0;
    font-size: 12px;
    color: #a0aec0;
    line-height: 20px;
}

/* Empty state */
.kramar-eb-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-eb-border);
    border-radius: var(--kramar-eb-radius);
    background: var(--kramar-eb-surface);
    min-height: 200px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    box-sizing: border-box;
    transition: border-color var(--kramar-eb-transition), background var(--kramar-eb-transition);
}
.kramar-eb-canvas__empty .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: var(--kramar-eb-text-light);
}
.kramar-eb-canvas__empty p {
    margin: 0;
    font-size: 13px;
    color: var(--kramar-eb-text-muted);
}
.kramar-eb-canvas__empty.is-drag-over {
    border-color: var(--kramar-eb-primary);
    background: var(--kramar-eb-primary-light);
}

/* ==========================================================================
   Blocks
   ========================================================================== */

.kramar-eb-block {
    position: relative;
    border: 2px solid transparent;
    transition: border-color var(--kramar-eb-transition), box-shadow var(--kramar-eb-transition);
    cursor: pointer;
    margin-bottom: 8px;
}
.kramar-eb-block:last-child { margin-bottom: 0; }
.kramar-eb-block:hover {
    border-color: #c3c4c7;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.kramar-eb-block--selected {
    border-color: var(--kramar-eb-primary) !important;
    box-shadow: 0 0 0 1px var(--kramar-eb-primary);
}

.kramar-eb-block--locked {
    cursor: default;
    opacity: 0.85;
    border-color: transparent !important;
}
.kramar-eb-block--locked:hover {
    border-color: transparent !important;
    box-shadow: none !important;
}

/* Content placeholder — hard divider between header/footer zones in template builder */
.kramar-eb-block--content-placeholder {
    opacity: 1 !important;
    border: none !important;
    padding: 0 !important;
    margin: 20px 0 !important;
    background: none !important;
}
.kramar-eb-content-placeholder {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
}
.kramar-eb-content-placeholder__line {
    flex: 1;
    height: 1px;
    background: #d0d5dd;
    border-top: 1px dashed #b0b5bd;
}
.kramar-eb-content-placeholder__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
    white-space: nowrap;
}

/* Block action bar (shown on hover/select) */
.kramar-eb-block__actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--kramar-eb-transition);
    z-index: 10;
}
.kramar-eb-block:hover .kramar-eb-block__actions,
.kramar-eb-block--selected .kramar-eb-block__actions {
    opacity: 1;
}

/* Individual action buttons — actual class names used in JS */
.kramar-eb-block__delete,
.kramar-eb-block__duplicate,
.kramar-eb-block__handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--kramar-eb-surface);
    border: 1px solid var(--kramar-eb-border);
    border-radius: var(--kramar-eb-radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--kramar-eb-text-muted);
    transition: all var(--kramar-eb-transition);
}
.kramar-eb-block__delete:hover,
.kramar-eb-block__duplicate:hover {
    color: var(--kramar-eb-text);
    border-color: #c3c4c7;
}
.kramar-eb-block__delete:hover {
    color: var(--kramar-eb-danger);
    border-color: var(--kramar-eb-danger);
    background: var(--kramar-eb-danger-light);
}
.kramar-eb-block__delete .dashicons,
.kramar-eb-block__duplicate .dashicons,
.kramar-eb-block__handle .dashicons {
    font-size: 13px;
    width: 13px;
    height: 13px;
}

/* Drag handle */
.kramar-eb-block__handle {
    position: static;
    cursor: grab;
}
.kramar-eb-block__handle:active { cursor: grabbing; }

/* Hover tooltip hint */
.kramar-eb-block__hint {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--kramar-eb-text-light);
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity var(--kramar-eb-transition);
}
.kramar-eb-block:hover .kramar-eb-block__hint { opacity: 1; }

/* Condition badge */
.kramar-eb-condition-badge {
    position: absolute;
    top: 4px;
    left: 24px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: #fff8e6;
    border: 1px solid #f0d060;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    color: #7a5800;
    z-index: 5;
}
.kramar-eb-condition-badge .dashicons {
    font-size: 11px;
    width: 11px;
    height: 11px;
}

/* Drop placeholder */
.kramar-eb-drop-placeholder {
    height: 44px;
    background: var(--kramar-eb-primary-light);
    border: 2px dashed rgba(127,84,179,.5);
    border-radius: var(--kramar-eb-radius-sm);
    margin: 2px 0;
    animation: kramarEbFadeIn 120ms ease;
}

/* Block deletion */
@keyframes kramarEbFadeOut {
    from { opacity: 1; transform: scaleY(1); }
    to   { opacity: 0; transform: scaleY(0); transform-origin: top; }
}
.kramar-eb-block--removing {
    animation: kramarEbFadeOut 180ms ease forwards;
}

@keyframes kramarEbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes kramarEbSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.kramar-eb-block--new {
    animation: kramarEbSlideIn 200ms ease;
}

/* Dragging ghost */
.kramar-eb-block--dragging { opacity: 0.3; }

/* ==========================================================================
   Block Content Area (actual class used in JS)
   ========================================================================== */

/* The block content is the real, server-rendered email HTML — it brings its
   own inline spacing/styling, so the wrapper stays neutral (the canvas
   container already supplies the email's 32px/40px padding). */
.kramar-eb-block__content {
    padding: 0;
    pointer-events: none;
}

/* Loading / empty placeholder shown until the server render arrives. */
.kramar-eb-block__placeholder {
    margin: 12px 16px;
    padding: 10px 12px;
    border: 1px dashed #dcdcde;
    border-radius: 4px;
    background: #fafbfc;
    color: #a0aec0;
    font-size: 13px;
}

/* Per-block-type preview styling intentionally removed: blocks now render
   the real email HTML (server-side), which is fully self-styled inline.
   Adding wrapper layout here (grids, flex, backgrounds, paddings) fought the
   real markup — e.g. an address-grid squashed the self-contained flex row. */

/* Image field — settings panel */
.kramar-eb-image-preview {
    background: var(--kramar-eb-surface-alt, #f9fafb);
    border: 1px solid var(--kramar-eb-border);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}
.kramar-eb-image-preview img {
    max-width: 100%;
    max-height: 140px;
    border-radius: 4px;
    display: block;
    margin: 0 auto 8px;
}
.kramar-eb-image-preview__actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}
.kramar-eb-image-remove {
    background: none;
    border: none;
    color: var(--kramar-eb-danger, #d63638);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}
.kramar-eb-image-empty {
    background: var(--kramar-eb-surface-alt, #f9fafb);
    border: 2px dashed var(--kramar-eb-border);
    border-radius: 6px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--kramar-eb-text-muted);
}
.kramar-eb-image-empty .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: var(--kramar-eb-text-light, #c3c4c7);
}

/* Merge field select (data-field block) */
.kramar-eb-merge-option--active {
    background: var(--kramar-eb-accent-light, #f0f0ff);
    font-weight: 600;
}

/* Divider block */
.kramar-eb-block--divider .kramar-eb-block__content {
    padding: 12px 24px;
}
.kramar-eb-divider {
    height: 0;
    border: none;
    border-top: 1px solid var(--kramar-eb-border);
    margin: 0;
}

/* Social block */
.kramar-eb-block--social .kramar-eb-block__content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
}
.kramar-eb-social-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--kramar-eb-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
}
.kramar-eb-social-icon .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Footer block */
.kramar-eb-block--footer .kramar-eb-block__content {
    padding: 16px 24px;
    text-align: center;
    font-size: 11px;
    color: var(--kramar-eb-text-light);
    line-height: 1.6;
    background: var(--kramar-eb-surface-alt);
}

/* Data field block */
.kramar-eb-block--data-field .kramar-eb-block__content {
    display: flex;
    gap: 6px;
    font-size: 13px;
    padding: 12px 24px;
}
.kramar-eb-data-field {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 13px;
}
.kramar-eb-data-label {
    font-weight: 600;
    color: var(--kramar-eb-text-muted);
    flex-shrink: 0;
}
.kramar-eb-data-value {
    color: var(--kramar-eb-text);
}

/* ==========================================================================
   Merge Tag Pills
   ========================================================================== */

.kramar-eb-merge-tag {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    background: var(--kramar-eb-primary-light);
    color: var(--kramar-eb-primary);
    border: 1px solid rgba(127,84,179,.25);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    white-space: nowrap;
}
.kramar-eb-merge-tag--invalid {
    background: var(--kramar-eb-danger-light);
    color: var(--kramar-eb-danger);
    border-color: var(--kramar-eb-danger);
    text-decoration: line-through;
    cursor: help;
    vertical-align: middle;
    line-height: 1.4;
}

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

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

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

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

.kramar-eb-settings__header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--kramar-eb-text);
}

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

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

/* Scrollable body */
.kramar-eb-settings__body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Settings form — actual class used in JS */
.kramar-eb-settings-form {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

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

/* Field wrapper — actual class used in JS (was .kramar-eb-field-row) */
.kramar-eb-field {
    margin-bottom: 14px;
}
.kramar-eb-field:last-child { margin-bottom: 0; }

/* Field label — actual class used in JS */
.kramar-eb-field__label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--kramar-eb-text);
    line-height: 1.4;
}

/* Input, textarea, select — actual classes used in JS */
.kramar-eb-field__input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--kramar-eb-border);
    border-radius: var(--kramar-eb-radius-sm);
    font-size: 13px;
    font-family: var(--kramar-eb-font);
    color: var(--kramar-eb-text);
    background: var(--kramar-eb-surface);
    outline: none;
    box-sizing: border-box;
    transition: border-color var(--kramar-eb-transition), box-shadow var(--kramar-eb-transition);
}
.kramar-eb-field__input:focus {
    border-color: var(--kramar-eb-primary);
    box-shadow: 0 0 0 2px rgba(127,84,179,.15);
}

.kramar-eb-field__textarea {
    resize: vertical;
    min-height: 72px;
    line-height: 1.5;
}

.kramar-eb-field__select {
    cursor: pointer;
}

/* Color input */
.kramar-eb-field__color {
    width: 40px;
    height: 32px;
    padding: 2px 3px;
    cursor: pointer;
    border: 1px solid var(--kramar-eb-border);
    border-radius: var(--kramar-eb-radius-sm);
    background: var(--kramar-eb-surface);
    flex-shrink: 0;
}

/* Color field — Global / Override pattern */
.kramar-eb-color-global {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}
.kramar-eb-color-swatch {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--kramar-eb-border);
    flex-shrink: 0;
}
.kramar-eb-color-source {
    font-size: 12px;
    color: var(--kramar-eb-text-muted);
    flex: 1;
}
.kramar-eb-color-override,
.kramar-eb-color-reset {
    background: none;
    border: none;
    font-size: 11px;
    color: var(--kramar-eb-accent);
    cursor: pointer;
    padding: 2px 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.kramar-eb-color-override:hover,
.kramar-eb-color-reset:hover {
    color: var(--kramar-eb-accent-hover, #4f46e5);
}
.kramar-eb-color-custom {
    display: flex;
    align-items: center;
    gap: 8px;
}
.kramar-eb-color-custom .kramar-eb-field__color {
    flex-shrink: 0;
}

/* Hex colour control — a typed hex field with a click-to-pick swatch.
   Used by the Global Colors sidebar and by per-block custom colours, so brand
   hex codes can be pasted straight in instead of hunted for in a picker. */
.kramar-eb-hex {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--kramar-eb-border);
    border-radius: var(--kramar-eb-radius-sm);
    background: var(--kramar-eb-surface);
    padding: 3px 6px 3px 3px;
    min-width: 0;
}
.kramar-eb-hex:focus-within {
    border-color: var(--kramar-eb-primary);
    box-shadow: 0 0 0 2px rgba(127,84,179,.15);
}
/* The native picker, shrunk to a swatch: still available for browsing colours,
   but no longer the only way in. */
.kramar-eb-hex__swatch {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--kramar-eb-border);
    border-radius: 3px;
    background: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.kramar-eb-hex__swatch::-webkit-color-swatch-wrapper { padding: 0; }
.kramar-eb-hex__swatch::-webkit-color-swatch { border: none; border-radius: 2px; }
.kramar-eb-hex__swatch::-moz-color-swatch { border: none; border-radius: 2px; }
/* Also carries .kramar-eb-field__input in per-block fields — the overrides
   below strip that class's own border/background so the wrapper is the only
   visible frame (hence the !important-free but more specific selector). */
.kramar-eb-hex .kramar-eb-hex__input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: none;
    outline: none;
    box-shadow: none;
    background: none;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 22px;
    color: var(--kramar-eb-text);
    text-transform: lowercase;
}
.kramar-eb-hex .kramar-eb-hex__input:focus {
    border: none;
    box-shadow: none;
}
.kramar-eb-hex__input::placeholder { color: var(--kramar-eb-text-muted); }
.kramar-eb-hex--invalid { border-color: #d63638; }
.kramar-eb-hex--invalid:focus-within { box-shadow: 0 0 0 1px #d63638; }

/* Global Colors rows in the palette sidebar.
   Label sits above its control: the sidebar is narrow and translated labels
   ("Pagina-achtergrond") are long, so a side-by-side row squeezed the hex value
   until it clipped. */
.kramar-eb-gcolor {
    display: block;
}
.kramar-eb-gcolor__label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--kramar-eb-text);
    line-height: 1.4;
}
.kramar-eb-gcolor__control {
    width: 100%;
}

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

/* Toggle field */
.kramar-eb-field--toggle {
    display: flex;
    align-items: center;
}
.kramar-eb-field__toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--kramar-eb-text);
}
.kramar-eb-field__toggle {
    width: 15px;
    height: 15px;
    accent-color: var(--kramar-eb-primary);
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

/* Legacy toggle row (keep for compat) */
.kramar-eb-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.kramar-eb-toggle-row input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--kramar-eb-primary);
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}
.kramar-eb-toggle-row span {
    font-size: 13px;
    color: var(--kramar-eb-text);
    cursor: pointer;
}

/* Color picker row */
.kramar-eb-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.kramar-eb-color-row input[type="color"] {
    width: 36px;
    height: 28px;
    padding: 2px;
    border: 1px solid var(--kramar-eb-border);
    border-radius: var(--kramar-eb-radius-sm);
    cursor: pointer;
    background: var(--kramar-eb-surface);
    flex-shrink: 0;
}
.kramar-eb-color-row .kramar-eb-field__input {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 12px;
}

/* ==========================================================================
   Visibility Section
   ========================================================================== */

.kramar-eb-visibility {
    border-top: 1px solid var(--kramar-eb-border-light);
    margin-top: 16px;
    padding-top: 14px;
}

.kramar-eb-visibility__title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--kramar-eb-text-light);
    margin: 0 0 10px;
}

.kramar-eb-visibility__type {
    width: 100%;
}

.kramar-eb-visibility__field-wrap {
    margin-top: 8px;
}

/* ==========================================================================
   Merge Field Insert
   ========================================================================== */

.kramar-eb-merge-insert {
    position: relative;
}

/* Merge select dropdown */
.kramar-eb-merge-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid rgba(127,84,179,.3);
    border-radius: var(--kramar-eb-radius-sm);
    font-size: 12px;
    font-family: var(--kramar-eb-font);
    color: var(--kramar-eb-primary);
    background: var(--kramar-eb-primary-light);
    cursor: pointer;
    outline: none;
    box-sizing: border-box;
    transition: border-color var(--kramar-eb-transition);
}
.kramar-eb-merge-select:focus {
    border-color: var(--kramar-eb-primary);
    box-shadow: 0 0 0 2px rgba(127,84,179,.15);
}

.kramar-eb-btn--merge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: var(--kramar-eb-primary-light);
    border: 1px solid rgba(127,84,179,.3);
    border-radius: var(--kramar-eb-radius-sm);
    color: var(--kramar-eb-primary);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--kramar-eb-font);
    cursor: pointer;
    transition: all var(--kramar-eb-transition);
}
.kramar-eb-btn--merge:hover {
    background: rgba(127,84,179,.15);
    border-color: rgba(127,84,179,.5);
}
.kramar-eb-btn--merge .dashicons { font-size: 12px; width: 12px; height: 12px; }

/* Merge field dropdown */
.kramar-eb-merge-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--kramar-eb-surface);
    border: 1px solid var(--kramar-eb-border);
    border-radius: var(--kramar-eb-radius);
    box-shadow: var(--kramar-eb-shadow-md);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}
.kramar-eb-merge-dropdown.is-open { display: block; }

.kramar-eb-merge-dropdown-wrap {
    position: relative;
}

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

.kramar-eb-merge-category {
    padding: 6px 10px 2px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--kramar-eb-text-light);
    border-top: 1px solid var(--kramar-eb-border-light);
}
.kramar-eb-merge-category:first-child { border-top: none; }

.kramar-eb-merge-option__label {
    font-size: 12px;
    color: var(--kramar-eb-text);
}

.kramar-eb-merge-dropdown__group {
    padding: 6px 10px 2px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--kramar-eb-text-light);
    border-top: 1px solid var(--kramar-eb-border-light);
}
.kramar-eb-merge-dropdown__group:first-child { border-top: none; }

.kramar-eb-merge-option {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    transition: background var(--kramar-eb-transition);
    font-size: 12px;
}
.kramar-eb-merge-option:hover { background: var(--kramar-eb-primary-light); }
.kramar-eb-merge-option__tag {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 11px;
    color: var(--kramar-eb-primary);
    font-weight: 600;
}
.kramar-eb-merge-option__preview {
    font-size: 11px;
    color: var(--kramar-eb-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

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

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

/* 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 field-builder strategy. */
@media (max-width: 1200px) {
    .kramar-eb-builder {
        grid-template-columns: 220px 1fr;
        grid-template-rows: auto auto;
    }
    .kramar-eb-palette {
        grid-row: 1 / 3;
    }
    .kramar-eb-settings {
        position: static;
        max-height: none;
    }
    .kramar-eb-toolbar {
        position: static;
        flex-wrap: wrap;
    }
}

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

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

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

.dark-mode .kramar-eb-canvas__email-container {
    background: #23282d;
}

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

.dark-mode .kramar-eb-toolbar__title,
.dark-mode .kramar-eb-settings__title,
.dark-mode .kramar-eb-field__label {
    color: #f0f0f1;
}

.dark-mode .kramar-eb-settings__subtitle,
.dark-mode .kramar-eb-input-hint {
    color: #a7aaad;
}

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

/* Hex colour control — match the panel's input surface, not the light default. */
.dark-mode .kramar-eb-hex {
    background: #2c3338;
    border-color: #3c434a;
}
.dark-mode .kramar-eb-hex__input {
    color: #f0f0f1;
    background: none;
}
.dark-mode .kramar-eb-hex__swatch {
    border-color: #3c434a;
}
.dark-mode .kramar-eb-gcolor__label {
    color: #f0f0f1;
}
/* The hex input is also a .kramar-eb-field__input in per-block fields; the
   generic dark rule would give it a second border/background inside the wrap. */
.dark-mode .kramar-eb-hex .kramar-eb-field__input {
    background: none;
    border: none;
}

.dark-mode .kramar-eb-merge-select {
    background: rgba(127,84,179,.2);
    border-color: rgba(127,84,179,.4);
    color: #c9a6f5;
}

.dark-mode .kramar-eb-block {
    border-color: transparent;
}
.dark-mode .kramar-eb-block:hover {
    border-color: #3c434a;
}
.dark-mode .kramar-eb-block__delete,
.dark-mode .kramar-eb-block__duplicate,
.dark-mode .kramar-eb-block__handle {
    background: #2c3338;
    border-color: #3c434a;
    color: #a7aaad;
}

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

.dark-mode .kramar-eb-merge-dropdown {
    background: #2c3338;
    border-color: #3c434a;
}
.dark-mode .kramar-eb-merge-option:hover {
    background: rgba(127,84,179,.2);
}

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

.dark-mode .kramar-eb-visibility {
    border-top-color: #3c434a;
}
