/**
 * Cadence — Editable entity drawer (OP/DP) + SP proposal picker styling.
 * Mission editable-op-dp-drawer-sp-proposals-01KXB2DV (WP05 follow-up: the
 * initial WP05 shipped the DOM without a stylesheet — this file styles it to
 * match the drawer's visual language, reusing the drawer design tokens
 * (--color-*, --radius-*, --shadow-*) documented in entity_drawer.css).
 */

/* ── Edit toolbar (view↔edit affordance) ─────────────────────────────────── */
.entity-drawer__edit-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin: 4px 0 12px;
}
.entity-drawer__edit-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Shared button base for the edit controls. */
.entity-drawer__edit-btn,
.entity-drawer__edit-save,
.entity-drawer__edit-cancel,
.sp-picker__add,
.sp-picker__result-btn,
.entity-drawer__edit-banner-reload {
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    padding: 8px 14px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, filter 0.12s ease;
}
.entity-drawer__edit-btn:hover,
.entity-drawer__edit-cancel:hover,
.sp-picker__add:hover,
.sp-picker__result-btn:hover,
.entity-drawer__edit-banner-reload:hover {
    border-color: var(--color-primary);
    background: var(--color-surface-2);
}
.entity-drawer__edit-save {
    border: 0;
    background: var(--color-primary, #4f46e5);
    color: #fff;
}
.entity-drawer__edit-save:hover:not(:disabled) { filter: brightness(1.08); }
.entity-drawer__edit-btn:disabled,
.entity-drawer__edit-save:disabled,
.entity-drawer__edit-cancel:disabled,
.sp-picker__add:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.entity-drawer__edit-cancel { color: var(--color-text-soft, var(--color-text)); }

/* ── Edit form fields ────────────────────────────────────────────────────── */
.entity-edit__form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.entity-edit__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.entity-edit__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
}
.entity-edit__input,
.entity-edit__select,
.entity-edit__textarea {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    font-size: 14px;
    padding: 8px 10px;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 6px);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.entity-edit__input:focus,
.entity-edit__select:focus,
.entity-edit__textarea:focus {
    outline: none;
    border-color: var(--color-primary, #4f46e5);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary, #4f46e5) 22%, transparent);
}
.entity-edit__textarea { min-height: 72px; resize: vertical; }
.entity-edit__input--invalid,
.entity-edit__input--invalid:focus {
    border-color: var(--color-danger, #dc2626);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger, #dc2626) 20%, transparent);
}

/* Multi-select (eligible profiles etc.) */
.entity-edit__multi {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
}
.entity-edit__multi-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--color-text);
}

/* Read-only field (guarded SC-ID, contacts) shown but not editable. */
.entity-edit__readonly {
    font-size: 14px;
    color: var(--color-text-soft, var(--color-text-muted));
    padding: 8px 10px;
    background: var(--color-surface-2);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm, 6px);
}
.entity-edit__error {
    font-size: 12px;
    color: var(--color-danger, #dc2626);
    min-height: 0;
}
.entity-edit__error:empty { display: none; }
.entity-edit__hint {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ── Save/conflict/rejection banner ──────────────────────────────────────── */
.entity-drawer__edit-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 0 0 12px;
    font-size: 13px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--color-border);
    background: var(--color-surface-2);
    color: var(--color-text);
}
.entity-drawer__edit-banner:empty { display: none; }
.entity-drawer__edit-banner--conflict {
    border-color: var(--color-warning, #d97706);
    background: color-mix(in srgb, var(--color-warning, #d97706) 10%, var(--color-surface));
}
.entity-drawer__edit-banner--error {
    border-color: var(--color-danger, #dc2626);
    background: color-mix(in srgb, var(--color-danger, #dc2626) 8%, var(--color-surface));
}
.entity-drawer__edit-banner-text { flex: 1 1 auto; }
.entity-drawer__edit-banner-slot { display: contents; }
.entity-drawer__edit-banner-reload { padding: 6px 12px; }

/* ── SP proposal picker ──────────────────────────────────────────────────── */
.sp-picker__search {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    font-size: 14px;
    padding: 8px 10px;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 6px);
}
.sp-picker__search:focus {
    outline: none;
    border-color: var(--color-primary, #4f46e5);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary, #4f46e5) 22%, transparent);
}
.sp-picker__results {
    list-style: none;
    margin: 4px 0 0;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 6px);
    background: var(--color-surface);
    max-height: 220px;
    overflow-y: auto;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(15, 23, 42, 0.12));
}
.sp-picker__results:empty { display: none; }
.sp-picker__result { margin: 0; }
.sp-picker__result-btn {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 7px 8px;
    border-radius: var(--radius-sm, 6px);
    font-weight: 500;
}
.sp-picker__result-btn:hover { background: var(--color-surface-2); border-color: transparent; }

.sp-picker__list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sp-picker__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 6px);
    background: var(--color-surface);
}
.sp-picker__name { flex: 1 1 auto; font-size: 14px; color: var(--color-text); }

/* Selected toggle — a chip that reads its state from aria-pressed. */
.sp-picker__toggle {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.sp-picker__toggle:hover { border-color: var(--color-primary); }
.sp-picker__toggle[aria-pressed="true"] {
    background: color-mix(in srgb, var(--color-success, #16a34a) 16%, var(--color-surface));
    border-color: var(--color-success, #16a34a);
    color: var(--color-success, #15803d);
}
.sp-picker__remove {
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 16px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
}
.sp-picker__remove:hover { color: var(--color-danger, #dc2626); background: var(--color-surface-2); }
.sp-picker__row[aria-busy="true"] { opacity: 0.6; pointer-events: none; }
.sp-picker__row-error {
    font-size: 12px;
    color: var(--color-danger, #dc2626);
    padding: 2px 2px 0;
}
.sp-picker__empty {
    font-size: 13px;
    padding: 4px 0;
}
