/**
 * Prompt Hub — Editor Styles
 * Double-layer highlight technique: textarea (transparent text) + overlay div (highlighted).
 *
 * Variables are defined in prompt-hub-public.css and inherited when both
 * stylesheets are enqueued together. They are redeclared here so the editor
 * styles also work when loaded independently (e.g. in admin context).
 */

:root {
    --ph-accent: #b89064;
    --ph-accent-hover: #9c7550;
    --ph-accent-light: rgba(184, 144, 100, 0.1);
    --ph-accent-mid: rgba(184, 144, 100, 0.18);
    --ph-bg: #f4f3f0;
    --ph-surface: #ffffff;
    --ph-surface-2: #f9f8f6;
    --ph-border: rgba(0, 0, 0, 0.08);
    --ph-border-strong: rgba(0, 0, 0, 0.14);
    --ph-text: #1a1814;
    --ph-text-muted: #6b6860;
    --ph-text-faint: #a8a69f;
    --ph-success: #2b2e32;
    --ph-success-hover: #303438;
    --ph-warning: #8a5a0a;
    --ph-danger: #7a1f1f;
    --ph-danger-hover: #5e1717;
    --ph-info: #3b5f82;
    --ph-radius-sm: 4px;
    --ph-radius: 8px;
    --ph-radius-lg: 12px;
    --ph-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --ph-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --ph-transition: all 0.2s ease;
    --ph-variable-bg: #eaf6ec;
    --ph-variable-text: #1d6b2e;
    --ph-variable-border: rgba(29, 107, 46, 0.22);
}

.prompt-hub-editor-container {
    position: relative;
    width: 100%;
    min-height: 200px;
}

.prompt-hub-editor-highlight,
.prompt-hub-editor {
    width: 100%;
    min-height: 200px;
    padding: 0.75rem 1rem;
    margin: 0;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-sm);
    font-family: "Courier New", Courier, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.prompt-hub-editor-highlight {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background-color: var(--ph-surface);
    color: var(--ph-text);
    overflow: hidden;
    z-index: 1;
}

.prompt-hub-editor-highlight .prompt-variable {
    background-color: var(--ph-variable-bg);
    color: var(--ph-variable-text);
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--ph-radius-sm);
    border: 1px solid var(--ph-variable-border);
}

.prompt-hub-editor {
    position: relative;
    z-index: 2;
    background-color: transparent;
    color: transparent;
    caret-color: var(--ph-text);
    resize: vertical;
    border-color: var(--ph-border);
}

.prompt-hub-editor:focus {
    outline: none;
    border-color: var(--ph-accent);
    box-shadow: 0 0 0 3px var(--ph-accent-light);
}

/* Live preview header + badge */
.prompt-hub-live-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.prompt-hub-live-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ph-text);
}

.prompt-hub-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.5rem;
    background-color: var(--ph-accent);
    color: var(--ph-surface);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.prompt-hub-var-id {
    font-family: "Courier New", Courier, monospace;
    font-size: 0.8em;
    font-weight: 400;
    background-color: var(--ph-border-strong);
    padding: 0.125rem 0.375rem;
    border-radius: var(--ph-radius-sm);
    color: var(--ph-text-muted);
    margin-left: 0.5rem;
}

/* Select inside highlight overlay should not be visible */
.prompt-hub-editor-highlight::selection {
    background-color: transparent;
}

.prompt-hub-editor::selection {
    background-color: var(--ph-accent-mid);
    color: transparent;
}

/* Live preview fields section */
#prompt_hub_live_fields {
    padding: 1rem 1.25rem;
    border: 1px dashed var(--ph-border);
    border-radius: var(--ph-radius-sm);
    background-color: var(--ph-surface-2);
}

#prompt_hub_live_fields .prompt-hub-label {
    margin-bottom: 0.25rem;
}

.prompt-hub-live-field {
    margin-bottom: 1rem;
}

.prompt-hub-live-field:last-child {
    margin-bottom: 0;
}

.prompt-hub-live-field .prompt-hub-input {
    min-height: 50px;
    resize: vertical;
}
