/* Constructor de correos (correos.js): lista de plantillas y editor de tres paneles (paleta, lienzo, configuración). */

main.wide:has(section[data-view="emails"]:not([hidden])) { max-width: 72rem; }
main.wide:has(section[data-view="email-editor"]:not([hidden])) { max-width: none; }

.ce-list-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.ce-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.ce-card { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.75rem; border: 1px solid #8884; border-radius: 10px; text-align: left; font: inherit; background: none; color: inherit; }
button.ce-card:hover { border-color: var(--brand); }
.ce-thumb { height: 12rem; overflow: hidden; border-radius: 6px; background: #f4f4f5; position: relative; }
.ce-thumb iframe { width: 300%; height: 300%; border: 0; transform: scale(0.3333); transform-origin: 0 0; pointer-events: none; background: #fff; }

.ce-dialog { width: min(60rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); border: 1px solid #8886; border-radius: 12px; padding: 1rem 1.25rem; }
.ce-dialog::backdrop { background: #0006; }
.ce-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.ce-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.ce-option { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.5rem 1rem; border: 2px dashed #8886; border-radius: 12px; background: none; color: inherit; font: inherit; text-align: left; }
.ce-option:hover, .ce-option:focus-visible { border-color: var(--brand); }
.ce-option strong { font-size: 1.1em; }

/* Editor */
.ce-top { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; }
.ce-top #ce-name { width: auto; flex: 1 1 14rem; margin: 0; font-weight: 600; }
.ce-top .actions { margin-left: auto; }
.ce-primary { background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 6px; }
.ce-warnings { margin: 0 0 0.5rem; padding-left: 1.2rem; color: #b45309; font-size: 0.9em; }
.ce-warnings:empty { display: none; }
.ce-layout { display: grid; grid-template-columns: 13rem minmax(0, 1fr) 19rem; gap: 0.75rem; align-items: start; }
.ce-palette, .ce-panel { position: sticky; top: 0.5rem; max-height: calc(100vh - 6rem); overflow-y: auto; border: 1px solid #8884; border-radius: 10px; padding: 0.75rem; box-sizing: border-box; }
.ce-panel h3 { margin-top: 0; }
.ce-tabs { display: flex; gap: 0.25rem; margin-bottom: 0.75rem; }
.ce-tabs button { flex: 1; padding: 0.4rem; border: 1px solid #8886; background: none; color: inherit; border-radius: 6px; }
.ce-tabs button.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.ce-palette-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.ce-palette-list { display: flex; flex-direction: column; gap: 0.4rem; }
.ce-palette-item { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; padding: 0.6rem 0.3rem; border: 1px solid #8886; border-radius: 8px; background: none; color: inherit; font: inherit; font-size: 0.85em; cursor: grab; }
.ce-palette-list .ce-palette-item { flex-direction: row; justify-content: flex-start; padding: 0.5rem 0.6rem; }
.ce-palette-item:hover { border-color: var(--brand); }
.ce-icon { font-size: 1.3em; font-weight: 700; line-height: 1; }
.ce-structure { display: flex; gap: 3px; width: 100%; height: 1.1rem; }
.ce-structure span { background: color-mix(in srgb, var(--brand) 40%, transparent); border-radius: 2px; }

.ce-stage { overflow-x: auto; border-radius: 10px; }
.ce-canvas { padding: 1.5rem 0.5rem; min-height: 70vh; border-radius: 10px; }
.ce-email { margin: 0 auto; max-width: 100%; color-scheme: light; color: #333; line-height: 1.5; box-shadow: 0 1px 4px #0002; }
.ce-email a { color: var(--ce-link); }
.ce-empty { padding: 3rem 1rem; text-align: center; color: #6b7280; border: 2px dashed #9ca3af; margin: 1rem; }
.ce-seg { position: relative; outline: 1px dashed transparent; }
.ce-seg:hover { outline-color: color-mix(in srgb, var(--brand) 53%, transparent); }
.ce-seg.is-selected { outline: 2px solid var(--brand); z-index: 1; }
.ce-tools { position: absolute; top: -1.6rem; right: 0; display: none; gap: 2px; z-index: 2; }
.ce-seg:hover > .ce-tools, .ce-seg.is-selected > .ce-tools { display: flex; }
.ce-tools button, .ce-seg-handle { padding: 0.1rem 0.45rem; font-size: 0.8rem; border: 0; border-radius: 4px; background: var(--brand); color: #fff; }
.ce-seg-handle { cursor: grab; user-select: none; }
.ce-row { display: flex; }
.ce-cell { box-sizing: border-box; min-height: 3rem; min-width: 0; }
.ce-cell-empty { margin: 0.4rem; padding: 1rem 0.5rem; border: 2px dashed #9ca3af; color: #6b7280; text-align: center; font-size: 0.85em; }
.ce-block { position: relative; outline: 1px dashed transparent; cursor: pointer; }
.ce-block:hover { outline-color: #16a34a88; }
.ce-block.is-selected { outline: 2px solid #16a34a; cursor: auto; }
.ce-text-body { outline: none; overflow-wrap: anywhere; }
.ce-text-body h1, .ce-text-body h2, .ce-text-body h3 { margin: 0.3em 0; }
.ce-text-body p { margin: 0 0 0.6em; }
.ce-text-body[contenteditable="true"] { cursor: text; min-height: 1.5em; }
.ce-image-wrap img { max-width: 100%; height: auto; vertical-align: top; }
.ce-image-empty { padding: 1.5rem 0.5rem; background: #e5e7eb; color: #4b5563; text-align: center; font-size: 0.85em; border-radius: 4px; overflow-wrap: anywhere; }
.ce-button-face { display: inline-block; padding: 12px 24px; font-weight: 600; line-height: 1.2; }
.ce-divider-line { margin: 0 auto; }
.ce-spacer-box { display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: #9ca3af; background: repeating-linear-gradient(45deg, transparent 0 6px, #9ca3af22 6px 12px); }
.ce-social-row, .ce-menu-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.ce-html-frame { display: block; width: 100%; height: 16rem; border: 0; background: #fff; pointer-events: none; }
.ce-badge { position: absolute; top: 2px; left: 2px; padding: 0 0.3rem; font-size: 0.7rem; background: #111827cc; color: #fff; border-radius: 3px; z-index: 1; }
.ce-drop-line { height: 4px; margin: 2px 0; background: var(--brand); border-radius: 2px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 33%, transparent); pointer-events: none; }

.ce-panel label { margin: 0.6rem 0; }
.ce-range { display: flex; align-items: center; gap: 0.5rem; }
.ce-range input { flex: 1; }
.ce-color { display: flex; align-items: center; gap: 0.75rem; }
.ce-color input[type="color"] { width: 3rem; height: 2rem; padding: 0.1rem; }
.ce-color label.check { margin: 0; }
.ce-text-tools button { padding: 0.3rem 0.6rem; }
.ce-text-tools input[type="color"] { width: 2.5rem; height: 2rem; padding: 0.1rem; margin: 0; }
.ce-gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; }
.ce-gallery p { grid-column: 1 / -1; margin: 0.2rem 0; }
.ce-thumb-img { padding: 2px; border: 2px solid transparent; background: #8882; border-radius: 4px; aspect-ratio: 1; }
.ce-thumb-img.is-selected { border-color: var(--brand); }
.ce-thumb-img img { width: 100%; height: 100%; object-fit: contain; }
.ce-list-item { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.25rem; padding: 0.4rem 0; border-bottom: 1px solid #8883; }
.ce-code { font-family: ui-monospace, monospace; font-size: 0.85em; }

.ce-preview { width: min(72rem, calc(100vw - 2rem)); }
.ce-preview-frame { display: flex; justify-content: center; background: #8882; border-radius: 8px; padding: 1rem 0; }
.ce-preview-frame iframe { width: 100%; height: 70vh; border: 0; background: #fff; transition: width 0.2s; }
.ce-preview-frame[data-size="mobile"] iframe { width: 375px; border: 10px solid #111827; border-radius: 24px; box-sizing: content-box; }

/* En pantallas angostas: la paleta arriba en una fila, el lienzo y luego la configuración. */
@media (max-width: 1000px) {
  .ce-layout { grid-template-columns: minmax(0, 1fr); }
  .ce-palette, .ce-panel { position: static; max-height: none; }
  .ce-palette-grid { grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); }
  .ce-canvas { padding: 0.75rem 0; }
  .ce-top .actions { margin-left: 0; }
}

/* Mis segmentos: el segmento guardado y su botón para quitarlo */
.ce-my-segment { display: flex; gap: 0.25rem; align-items: stretch; }
.ce-my-segment .ce-palette-item { flex: 1; min-width: 0; }
.ce-my-delete { padding: 0 0.5rem; border: 1px solid #8886; border-radius: 8px; background: none; color: inherit; }

/* Probar (como Stripo): pestañas con contador, simulaciones de clientes, links y puntaje de spam. */
.ce-test { width: min(72rem, calc(100vw - 2rem)); }
.ce-test-tabs { flex-wrap: wrap; margin: 0.5rem 0 1rem; }
.ce-count { display: inline-block; min-width: 1.3em; margin-left: 0.35em; padding: 0 0.35em; border-radius: 999px; background: #d93025; color: #fff; font-size: 0.75em; line-height: 1.5; }
.ce-test-recipient { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.ce-test-recipient input { flex: 1; }
.ce-test-issue { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.5rem 0.75rem; border-radius: 8px; margin: 0.4rem 0; border-left: 4px solid #9aa0a6; background: #8881; }
.ce-test-issue.ok { border-left-color: #188038; }
.ce-test-issue.warn { border-left-color: #f29900; }
.ce-test-issue.bad { border-left-color: #d93025; }
.ce-points { font-weight: bold; white-space: nowrap; }
.ce-inbox-row { display: flex; gap: 1rem; align-items: baseline; padding: 0.6rem 0.75rem; border: 1px solid #8884; border-radius: 8px; background: #fff; color: #202124; overflow: hidden; }
.ce-inbox-row strong { flex: 0 0 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ce-inbox-line { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #5f6368; }
.ce-inbox-line b { color: #202124; }
.ce-clients { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.ce-client { margin: 0; text-align: center; }
.ce-client iframe { width: 100%; height: 26rem; border: 1px solid #8884; border-radius: 8px; background: #fff; }
.ce-client.is-mobile iframe { width: 100%; max-width: 20rem; }
.ce-client figcaption { font-size: 0.85em; opacity: 0.8; margin-top: 0.25rem; }
.ce-plain { white-space: pre-wrap; max-height: 20rem; overflow: auto; font-size: 0.85em; }
.ce-links { width: 100%; }
.ce-link-url { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ce-pill { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8em; background: #8882; }
.ce-pill.ok { background: #e6f4ea; color: #137333; }
.ce-pill.warn { background: #fef7e0; color: #b06000; }
.ce-pill.bad { background: #fce8e6; color: #c5221f; }
.ce-spam-score { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.75rem; border-radius: 8px; background: #8881; }
.ce-spam-score strong { font-size: 1.5em; }
.ce-spam-score meter { flex: 1; min-width: 8rem; height: 1rem; }
@media (max-width: 600px) {
  .ce-inbox-row strong { flex-basis: 5rem; }
  .ce-links th:first-child, .ce-links td:first-child { display: none; }
  .ce-link-url { max-width: 9rem; }
}
