/* <correo-redactor> y la tarjeta de redacción (.cr-compose) estilo Gmail — prefactura.
   Todo bajo .cr / .cr-compose (Bootstrap 3 es global). */

correo-redactor { display: block; }

.cr { position: relative; display: flex; flex-direction: column; text-align: left; background: #fff; }
.cr-linea { flex-direction: row; align-items: center; gap: 6px; }

/* Área editable */
.cr-area {
    position: relative; min-height: 170px; max-height: 46vh; overflow-y: auto;
    padding: 10px 12px; outline: 0; cursor: text;
    font-size: 14px; line-height: 1.55; color: #222; word-wrap: break-word; overflow-wrap: anywhere;
}
.cr-area p, .cr-area div { margin: 0 0 .35em; }
.cr-area ul, .cr-area ol { margin: 0 0 .5em; padding-left: 24px; }
.cr-linea { align-items: flex-start; }
.cr-linea .cr-area {
    flex: 1; min-width: 0; min-height: 0; max-height: none; padding: 5px 0;
    overflow: visible; font-size: 13.5px; line-height: 1.7;
}
.cr-linea .cr-bar { margin-top: 3px; }
.cr-area.cr-vacio::before {
    content: attr(data-placeholder); position: absolute; color: #9aa4af; pointer-events: none;
}

/* Variable: se ve como una etiqueta, viaja como {clave} */
.cr-var {
    display: inline-block; padding: 0 7px; margin: 0 1px; border-radius: 10px;
    background: #e8f1fa; border: 1px solid #b9d3ee; color: #165a99;
    font-size: .9em; font-weight: 600; line-height: 1.5; white-space: nowrap; vertical-align: baseline;
    cursor: default; user-select: all;
}

/* Barra de formato (abajo, como Gmail) */
.cr-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
    padding: 4px 8px; border-top: 1px solid #edf0f4; background: #fafbfc;
}
.cr-linea .cr-bar { border: 0; background: transparent; padding: 0; }
.cr-btn {
    display: inline-flex; align-items: center; gap: 4px; height: 28px; min-width: 28px; padding: 0 7px;
    border: 1px solid transparent; border-radius: 4px; background: transparent; color: #44515e; font-size: 13px; cursor: pointer;
}
.cr-btn:hover { background: #eaeef2; }
.cr-btn.is-on { background: #dce8f5; color: #165a99; }
.cr-btn:focus { outline: 0; }
.cr-btn:focus-visible { outline: 2px solid #1a6bb5; outline-offset: 1px; }
.cr-btn-dato { color: #165a99; font-weight: 600; }
.cr-linea .cr-btn-dato { height: 24px; font-size: 12px; border-color: #c4d6e8; background: #fff; }
.cr-sep { width: 1px; height: 18px; margin: 0 6px; background: #d6dde5; }

.cr-vars { position: relative; }
.cr-menu {
    position: absolute; left: 0; bottom: 100%; z-index: 40; min-width: 250px; max-height: 300px; overflow-y: auto;
    margin: 0 0 4px; padding: 4px 0; list-style: none;
    background: #fff; border: 1px solid rgba(0, 0, 0, .15); border-radius: 6px; box-shadow: 0 8px 18px rgba(0, 0, 0, .16);
}
.cr-linea .cr-menu { left: auto; right: 0; top: 100%; bottom: auto; margin: 4px 0 0; }
.cr-menu button {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%;
    padding: 6px 12px; border: 0; background: transparent; text-align: left; font-size: 13px; color: #1f2d3a; cursor: pointer;
}
.cr-menu button:hover, .cr-menu button:focus { background: #e8f1fa; outline: 0; }
.cr-menu-ej { color: #7a8693; font-size: 12px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Tarjeta de redacción (.cr-compose) ─────────────────────────── */
.cr-compose {
    position: relative; text-align: left;
    background: #fff; border: 1px solid #d6dde5; border-radius: 8px;
    box-shadow: 0 1px 2px rgba(31, 45, 58, .06);
}
.cr-compose > :first-child { border-top-left-radius: 8px; border-top-right-radius: 8px; }
.cr-fila {
    display: flex; align-items: flex-start; gap: 8px;
    min-height: 40px; padding: 4px 12px; border-bottom: 1px solid #edf0f4;
}
.cr-fila > label, .cr-fila > .cr-fila-lbl {
    flex: 0 0 56px; margin: 7px 0 0; font-size: 13px; font-weight: 400; color: #5f6b78;
}
.cr-fila > .cr-campo { flex: 1; min-width: 0; }
.cr-fila-acc { flex: 0 0 auto; display: flex; gap: 10px; margin-top: 7px; font-size: 13px; }
.cr-fila-acc a { color: #44515e; }
.cr-fila-acc a:hover { color: #1a6bb5; text-decoration: underline; }
.cr-fila.has-error > label { color: #a94442; font-weight: 600; }
.cr-input {
    width: 100%; height: 30px; padding: 4px 0; border: 0; outline: 0; background: transparent;
    font-size: 13.5px; color: #222; box-shadow: none;
}

/* <email-chips> dentro de una fila: sin caja propia, el pie solo muestra errores/avisos */
.cr-fila .ec-chips .ec-box { border: 0; box-shadow: none; padding: 4px 0; min-height: 30px; background: transparent; }
.cr-fila .ec-chips.ec-focus .ec-box, .cr-fila .ec-chips .ec-box:focus-within { box-shadow: none; }
.cr-fila .ec-chips .ec-foot { margin: 0 0 3px; }
.cr-fila .ec-chips .ec-count, .cr-fila .ec-chips .ec-help { display: none; }

/* Adjuntos */
.cr-adjuntos {
    display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-top: 1px solid #edf0f4;
}
.cr-adj {
    position: relative; display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
    margin: 0; padding: 6px 8px 6px 10px; border: 1px solid #d6dde5; border-radius: 6px;
    background: #f7f9fb; font-size: 12.5px; font-weight: 400; color: #1f2d3a; cursor: pointer;
    transition: border-color .15s, background .15s, opacity .15s;
}
.cr-adj:hover { border-color: #aac3dc; }
.cr-adj > .fa { font-size: 18px; flex-shrink: 0; }
.cr-adj-xls > .fa { color: #1e7e34; }
.cr-adj-pdf > .fa { color: #c0392b; }
.cr-adj-otro > .fa { color: #5f6b78; }
.cr-adj-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.cr-adj-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; font-weight: 600; }
.cr-adj-d { font-size: 11.5px; color: #6b7785; }
.cr-adj input[type="checkbox"] { margin: 0; flex-shrink: 0; }
.cr-adj.is-off { background: #fff; border-style: dashed; opacity: .65; }
.cr-adj.is-off .cr-adj-n { text-decoration: line-through; font-weight: 400; }
.cr-adj.is-na { cursor: not-allowed; opacity: .5; }
.cr-adj-x {
    flex-shrink: 0; width: 22px; height: 22px; margin-left: 2px; padding: 0; border: 0; border-radius: 50%;
    background: transparent; color: #6b7785; font-size: 16px; line-height: 20px; cursor: pointer;
}
.cr-adj-x:hover { background: #fdecea; color: #b3261e; }
.cr-adj-x:focus-visible, .cr-adj input:focus-visible { outline: 2px solid #1a6bb5; outline-offset: 1px; }
.cr-adj-add {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
    border: 1px dashed #aac3dc; border-radius: 6px; background: #fff; color: #165a99; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.cr-adj-add:hover { background: #e8f1fa; }
.cr-nota { margin: 0; padding: 0 12px 10px; font-size: 12px; color: #6b7785; }

/* Arrastrar archivos sobre la tarjeta */
.cr-compose.cr-arrastrando::after {
    content: 'Suelta los archivos para adjuntarlos';
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    border: 2px dashed #1a6bb5; border-radius: 8px; background: rgba(232, 241, 250, .92);
    color: #165a99; font-size: 15px; font-weight: 600; pointer-events: none;
}

@media (max-width: 767px) {
    .cr-fila > label, .cr-fila > .cr-fila-lbl { flex-basis: 44px; }
    .cr-area { min-height: 140px; font-size: 16px; }   /* 16px evita el zoom de iOS */
    .cr-linea .cr-area, .cr-input { font-size: 16px; }
    .cr-adj-n { max-width: 180px; }
}

@media (prefers-reduced-motion: reduce) {
    .cr-adj { transition: none; }
}
