/* EDITOR.css */

/* ── Editor shell ───────────────────────────────────────── */

#editor {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--c1);
    position: relative;
    z-index: 1;
}

/* ── Header ─────────────────────────────────────────────── */

.ed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 16px;
    height: 48px;
    border-bottom: 1px solid var(--border-dim);
    flex-shrink: 0;
    background: var(--c1);
    gap: 12px;
}

.ed-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.ed-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ed-header-hash {
    font-size: 20px;
    color: var(--text-faint);
    font-family: var(--font-ui);
    font-weight: var(--fw-regular);
    line-height: 1;
    margin-top: -2px;
    flex-shrink: 0;
}

/* título do header — maior e mais brilhante para âncora visual */
.ed-header-title {
    font-size: var(--p15);
    color: var(--text-bright);
    font-weight: var(--fw-semi);        /* 600 */
    font-family: var(--font-ui);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ed-header-divider {
    width: 1px;
    height: 20px;
    background: var(--border-dim);
    margin: 0 2px;
    flex-shrink: 0;
}

/* ── Header save button ─────────────────────────────────── */

.ed-header-save-status {
    font-size: var(--p12);
    font-family: var(--font-ui);
    font-weight: var(--fw-medium);
    white-space: nowrap;
}

.ed-header-status-ok  { color: var(--success); }
.ed-header-status-err { color: var(--danger); }

.ed-header-save-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    height: 30px;
    border: none;
    border-radius: 3px;
    background: var(--accent);
    color: #fff;
    font-size: var(--p13);
    font-family: var(--font-ui);
    font-weight: var(--fw-semi);
    letter-spacing: 0.01em;
    cursor: pointer;
    transition:
        filter    var(--t-fast),
        transform var(--t-fast) var(--ease-snap),
        background var(--t-fast),
        opacity   var(--t-fast);
    white-space: nowrap;
}

.ed-header-save-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.ed-header-save-btn:hover  { filter: brightness(1.14); }
.ed-header-save-btn:active { transform: scale(0.96); }
.ed-header-save-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.ed-header-save-btn--loading { background: var(--accent-dim); }
.ed-header-save-btn--ok      { background: var(--success) !important; }
.ed-header-save-btn--err     { background: var(--danger) !important; }

/* ── Tab wrapper ────────────────────────────────────────── */

.ed-tab-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ── Tab strip ──────────────────────────────────────────── */

.ed-tab-strip {
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-dim);
    background: var(--c1);
    flex-shrink: 0;
    gap: 2px;
}

.ed-tab {
    padding: 0 6px;
    height: 40px;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-muted);          /* mais apagado quando inativo */
    font-size: 12px;
    font-family: var(--font-ui);
    font-weight: var(--fw-semi);       /* 600 — tabs são navegação, devem destacar */
    letter-spacing: 0.025em;
    text-transform: uppercase;
    cursor: pointer;
    margin-bottom: -1px;
    transition:
        color        var(--t-fast) var(--ease-out),
        border-color var(--t-fast) var(--ease-out);
    white-space: nowrap;
}

.ed-tab:hover        { color: var(--text-dim); }
.ed-tab.ed-tab-active {
    color: var(--text-bright);
    border-bottom-color: var(--accent);
}

/* ── Tab content ────────────────────────────────────────── */

.ed-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px 16px;
    scrollbar-width: thin;
}

.ed-tab-content > * + * { margin-top: 6px; }

/* ── Collapsible section ────────────────────────────────── */

.ed-collapsible {
    border-radius: 4px;
    background: var(--s1);
    border: 1px solid var(--border-dim);
}

.ed-collapsible + .ed-collapsible { margin-top: 2px; }

.ed-collapsible-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 11px;
    font-family: var(--font-ui);
    font-weight: var(--fw-bold);       /* 700 — cabeçalho de seção é âncora visual */
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition:
        background var(--t-fast) var(--ease-out),
        color      var(--t-fast) var(--ease-out);
}

.ed-collapsible-header:hover {
    background: var(--s2);
    color: var(--text);
}

.ed-collapsible-header .ed-chevron {
    width: 11px;
    height: 11px;
    color: var(--text-faint);
    flex-shrink: 0;
    transform: rotate(-90deg);
    transition: transform var(--t-med) var(--ease-snap), color var(--t-fast);
}

.ed-collapsible-open .ed-chevron {
    transform: rotate(0deg);
    color: var(--accent);
}

.ed-collapsible-open { color: var(--text-bright); }

/* body — transição suave de altura */
.ed-body-inner {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--c1);
    border-top: 1px solid var(--border-dim);

    clip-path: inset(0 0 100% 0);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    transition:
        clip-path      var(--t-med) var(--ease-out),
        max-height     var(--t-med) var(--ease-out),
        padding-top    var(--t-med) var(--ease-out),
        padding-bottom var(--t-med) var(--ease-out);
}

.ed-body-inner.ed-body-inner-open {
    clip-path: inset(0 0 -200px 0);
    max-height: 9999px;
    padding-top: 12px;
    padding-bottom: 12px;
}

/* ── Body (renderizações diretas) ───────────────────────── */

.ed-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Card ───────────────────────────────────────────────── */

.ed-cards {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ed-card {
    background: var(--s1);
    border: 1px solid var(--border-dim);
    border-radius: 4px;
    animation: cardIn var(--t-med) var(--ease-out) both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ed-card-open {
    border-color: rgba(59, 130, 246, 0.18);  /* sutil azul quando aberto */
}

.ed-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 12px;
    height: 38px;
    cursor: pointer;
    user-select: none;
    transition: background var(--t-fast) var(--ease-out);
}

.ed-card-header:hover { background: var(--s2); }

/* título do card: peso médio, cor intermediária — claramente abaixo do collapsible */
.ed-card-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: var(--p13);
    color: var(--text-dim);
    font-weight: var(--fw-medium);     /* 500 */
    font-family: var(--font-ui);
    letter-spacing: 0;
}

/* quando card aberto: texto mais claro mas sem uppercase */
.ed-card-open .ed-card-title { color: var(--text); }

.ed-chevron {
    width: 11px;
    height: 11px;
    color: var(--text-faint);
    transition: transform var(--t-med) var(--ease-snap), color var(--t-fast);
}

.ed-card-open .ed-chevron {
    transform: rotate(0deg);
    color: var(--accent);
}

.ed-card:not(.ed-card-open) .ed-chevron { transform: rotate(-90deg); }

.ed-card-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    border-radius: 3px;
    transition:
        color      var(--t-fast) var(--ease-out),
        background var(--t-fast) var(--ease-out);
}

.ed-card-remove:hover {
    color: var(--danger);
    background: var(--danger-dim);
}

.ed-card-remove svg { width: 13px; height: 13px; }

.ed-card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--border-dim);
    background: rgba(0,0,0,0.12);      /* leve profundidade no corpo do card */
}

.ed-card:not(.ed-card-open) .ed-card-body { display: none; }

/* ── Section dividers ───────────────────────────────────── */

.ed-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* label de seção — nível mais baixo da hierarquia, bem discreto */
.ed-section-label {
    font-size: 10px;
    font-weight: var(--fw-bold);       /* 700 mas pequeno = discreto */
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-dim);
    font-family: var(--font-ui);
}

/* ── Rows & Fields ──────────────────────────────────────── */

.ed-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.ed-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.ed-field.flex-1 { flex: 1; }
.ed-field.flex-2 { flex: 2; }
.ed-field.flex-3 { flex: 3; }
.ed-field.ed-field-full { flex: 1 0 100%; }

/* label do campo: menor e mais esmaecido que tudo acima */
.ed-label {
    font-size: 10px;
    color: var(--text-faint);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-family: var(--font-ui);
    transition: color var(--t-fast);
}

.ed-field:focus-within .ed-label { color: var(--accent); }

/* ── Inputs ─────────────────────────────────────────────── */

.ed-input {
    background: var(--f-c1);
    border: 1px solid var(--f-border);
    border-radius: 3px;
    color: var(--text);
    font-size: var(--p14);
    font-weight: var(--fw-regular);
    padding: 7px 10px;
    width: 100%;
    outline: none;
    transition:
        border-color var(--t-fast) var(--ease-out),
        box-shadow   var(--t-fast) var(--ease-out);
    font-family: var(--font-ui);
    line-height: 1.4;
}

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

.ed-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}

.ed-input:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Textarea ───────────────────────────────────────────── */

.ed-textarea {
    background: var(--f-c1);
    border: 1px solid var(--f-border);
    border-radius: 3px;
    color: var(--text);
    font-size: var(--p13);             /* ligeiramente menor para diferir do input */
    font-weight: var(--fw-regular);
    padding: 8px 10px;
    width: 100%;
    outline: none;
    resize: vertical;
    min-height: 68px;
    font-family: var(--font-ui);
    line-height: 1.6;
    transition:
        border-color var(--t-fast) var(--ease-out),
        box-shadow   var(--t-fast) var(--ease-out);
}

.ed-textarea::placeholder { color: var(--text-faint); }

.ed-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}

/* ── Color input ─────────────────────────────────────────── */

.ed-color-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--f-c1);
    border: 1px solid var(--f-border);
    border-radius: 3px;
    padding: 5px 10px;
    transition: border-color var(--t-fast) var(--ease-out);
}

.ed-color-wrap:focus-within { border-color: var(--accent); }

.ed-color {
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    border-radius: 2px;
    flex-shrink: 0;
}

.ed-color::-webkit-color-swatch-wrapper { padding: 0; }
.ed-color::-webkit-color-swatch { border: none; border-radius: 2px; }

.ed-color-text {
    background: none;
    border: none;
    flex: 1;
    font-size: var(--p13);
    color: var(--text);
    font-family: var(--font-mono);
    outline: none;
}

/* ── Toggle ──────────────────────────────────────────────── */

.ed-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.ed-toggle input { display: none; }

.ed-toggle-track {
    width: 34px;
    height: 18px;
    background: rgba(255,255,255,0.07);
    border-radius: 9px;
    position: relative;
    transition: background var(--t-med) var(--ease-out);
}

.ed-toggle-track::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform var(--t-med) var(--ease-snap);
    opacity: 0.3;
}

.ed-toggle input:checked + .ed-toggle-track { background: var(--accent); }
.ed-toggle input:checked + .ed-toggle-track::after { transform: translateX(16px); opacity: 1; }

/* ── Style buttons ───────────────────────────────────────── */

.ed-style-btns { display: flex; gap: 5px; flex-wrap: wrap; }

.ed-style-btn {
    padding: 4px 12px;
    border-radius: 3px;
    border: 1px solid var(--border-dim);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--p12);
    font-family: var(--font-ui);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition:
        background   var(--t-fast) var(--ease-out),
        color        var(--t-fast) var(--ease-out),
        border-color var(--t-fast) var(--ease-out);
}

.ed-style-btn:hover {
    background: var(--s2);
    color: var(--text);
    border-color: var(--border);
}

.ed-style-btn-active {
    background: var(--btn-color) !important;
    border-color: transparent !important;
    color: #fff !important;
}

/* ── Array list ──────────────────────────────────────────── */

.ed-array-list { display: flex; flex-direction: column; gap: 3px; }

.ed-array-item { display: flex; gap: 6px; align-items: center; }
.ed-array-item .ed-input { flex: 1; }

.ed-array-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-faint);
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 3px;
    flex-shrink: 0;
    transition:
        color      var(--t-fast) var(--ease-out),
        background var(--t-fast) var(--ease-out);
}

.ed-array-remove:hover { color: var(--danger); background: var(--danger-dim); }
.ed-array-remove svg { width: 13px; height: 13px; }

/* ── Add buttons ─────────────────────────────────────────── */

.ed-add-btn {
    background: none;
    border: 1px dashed rgba(255,255,255,0.07);
    border-radius: 3px;
    color: var(--text-faint);
    font-size: var(--p12);
    font-family: var(--font-ui);
    font-weight: var(--fw-medium);
    padding: 6px;
    width: 100%;
    cursor: pointer;
    transition:
        border-color var(--t-fast) var(--ease-out),
        color        var(--t-fast) var(--ease-out),
        background   var(--t-fast) var(--ease-out);
}

.ed-add-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-muted);
}

.ed-add-btn-sm { padding: 3px 10px; width: auto; align-self: flex-start; }

.ed-add-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: rgba(255,255,255,0.04);
    color: var(--text-faint);
}

.ed-add-btn:disabled:hover {
    background: none;
    border-color: rgba(255,255,255,0.04);
    color: var(--text-faint);
}

/* ── Select ──────────────────────────────────────────────── */

.ed-custom-select { position: relative; width: 100%; }

.ed-custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    gap: 8px;
}

.ed-custom-select-trigger::after {
    content: "";
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9L12 15L18 9' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    transition: transform 0.15s;
}

.ed-custom-select-open .ed-custom-select-trigger::after { transform: rotate(180deg); }

.ed-custom-select-dropdown {
    display: none;
    position: fixed;
    background: var(--c2);
    border: 1px solid var(--border);
    border-radius: 4px;
    z-index: 9000;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    min-width: 160px;
}

.ed-custom-select-dropdown.ed-custom-select-dropdown-open { display: block; }

.ed-custom-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    cursor: pointer;
    gap: 8px;
    font-size: var(--p13);
    font-weight: var(--fw-medium);
    transition: background 0.1s;
}

.ed-custom-select-option:hover      { background: var(--s2); }
.ed-custom-select-option-active     { background: var(--s2); }
.ed-select-empty                    { color: var(--text-faint); font-style: italic; }

.ed-select-name {
    color: var(--text);
    font-size: var(--p13);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ed-select-id {
    color: var(--text-faint);
    font-size: 11px;
    font-family: var(--font-mono);
    flex-shrink: 0;
    opacity: 0.5;
}

.ed-select-placeholder { color: var(--text-muted); font-style: italic; }

/* ── Drag & Drop ─────────────────────────────────────────── */

.ed-drag-handle {
    width: 14px;
    height: 14px;
    color: var(--text-faint);
    cursor: grab;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.12s;
}

.ed-card-header:hover .ed-drag-handle { opacity: 0.5; }
.ed-drag-handle:active                { cursor: grabbing; }

.ed-dragging  { opacity: 0.3; border-style: dashed !important; }
.ed-drag-over { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Toast tray ──────────────────────────────────────────── */

#ed-toast-tray {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 9999;
    pointer-events: none;
}

.ed-toast {
    background: #1a2335;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: var(--p13);
    font-family: var(--font-ui);
    font-weight: var(--fw-medium);
    padding: 9px 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    opacity: 0;
    transform: translateY(8px);
    transition:
        opacity   var(--t-med) var(--ease-out),
        transform var(--t-med) var(--ease-out);
    max-width: 280px;
}

.ed-toast--in {
    opacity: 1;
    transform: translateY(0);
}

.ed-toast--warn    { border-color: var(--warn); color: var(--warn); }
.ed-toast--autosave { border-color: var(--border); color: var(--text-dim); }