/* [COMUNICACIONES OCT 2026] Panel «📣 Comunicaciones» (Administración) + aviso al entrar — look & feel Apple (mismos tokens
   --ad-* que admin-apple-redesign.css / organizacion.css). OJO: style.css oculta TODOS los checkbox nativos de panel.html
   (opacity 0, width 0); aquí los canales son interruptores (.com-switch) y la lista de destinatarios recupera la casilla nativa. */
#comunicacionesSection { font-family: var(--ad-font, -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif); color: var(--ad-text, #1d1d1f); }
.com-wrap { display: flex; flex-direction: column; gap: 16px; max-width: 1400px; }

/* ── Reset de la regla global `.section button` (style.css) para los botones propios ──────────────────────────────── */
#comunicacionesSection .com-btn, #comunicacionesSection .com-seg-btn, #comunicacionesSection .com-chip-btn,
#comunicacionesSection .com-toolbar button, #comunicacionesSection .com-link, #comunicacionesSection .com-x {
  margin: 0 !important; position: static !important; overflow: visible !important; box-shadow: none !important;
  background-image: none !important; transform: none !important; font-family: inherit !important; line-height: 1.2 !important;
}
#comunicacionesSection .com-btn::before, #comunicacionesSection .com-seg-btn::before, #comunicacionesSection .com-chip-btn::before,
#comunicacionesSection .com-toolbar button::before, #comunicacionesSection .com-link::before, #comunicacionesSection .com-x::before { content: none !important; display: none !important; }

/* ── Botones pastilla ─────────────────────────────────────────────────────── */
#comunicacionesSection .com-btn, .com-aviso-modal .com-btn, .com-modal .com-btn {
  display: inline-flex !important; align-items: center !important; gap: 6px !important;
  padding: 9px 16px !important; border-radius: var(--ad-r-pill, 980px) !important; border: 1px solid transparent !important;
  font-size: 13px !important; font-weight: 600 !important; cursor: pointer !important; white-space: nowrap !important;
  transition: transform .1s ease, filter .15s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease !important;
}
#comunicacionesSection .com-btn:disabled, .com-aviso-modal .com-btn:disabled { opacity: .55 !important; cursor: default !important; }
#comunicacionesSection .com-btn--pri, .com-aviso-modal .com-btn--pri { background: linear-gradient(135deg, #f0974a 0%, var(--ad-accent, #e88732) 100%) !important; background-image: linear-gradient(135deg, #f0974a 0%, var(--ad-accent, #e88732) 100%) !important; color: #fff !important; box-shadow: 0 4px 14px rgba(232,135,50,.28) !important; }
#comunicacionesSection .com-btn--pri:hover, .com-aviso-modal .com-btn--pri:hover { transform: translateY(-1px) !important; filter: saturate(1.08) !important; box-shadow: 0 8px 22px rgba(232,135,50,.38) !important; }
#comunicacionesSection .com-btn--sec { background: var(--ad-card, #fff) !important; color: var(--ad-text, #1d1d1f) !important; border-color: var(--ad-border-2, rgba(0,0,0,.14)) !important; }
#comunicacionesSection .com-btn--sec:hover { background: color-mix(in srgb, var(--ad-text-2, #6e6e73) 8%, var(--ad-card, #fff)) !important; border-color: var(--ad-text-3, #a1a1a6) !important; transform: translateY(-1px) !important; }
#comunicacionesSection .com-btn--ghost { background: transparent !important; color: var(--ad-text-2, #6e6e73) !important; border-color: transparent !important; padding: 6px 10px !important; }
#comunicacionesSection .com-btn--ghost:hover { background: color-mix(in srgb, var(--ad-text, #1d1d1f) 6%, transparent) !important; color: var(--ad-text, #1d1d1f) !important; }
#comunicacionesSection .com-btn--mini { padding: 6px 12px !important; font-size: 12px !important; }

/* ── Cabecera y KPIs ──────────────────────────────────────────────────────── */
.com-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.com-title { margin: 0; font-size: 1.9rem; font-weight: 700; letter-spacing: -.025em; color: var(--ad-text, #1d1d1f); }
.com-sub { margin: 6px 0 0; color: var(--ad-text-2, #6e6e73); font-size: 13.5px; max-width: 760px; line-height: 1.45; }
.com-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.com-kpi { background: var(--ad-card, #fff); border: 1px solid var(--ad-border, rgba(0,0,0,.08)); border-radius: var(--ad-r-card, 18px); box-shadow: var(--ad-sh, 0 1px 3px rgba(0,0,0,.05)); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden; }
.com-kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--ad-text, #1d1d1f); line-height: 1.1; font-variant-numeric: tabular-nums; }
.com-kpi .v small { font-size: 13px; font-weight: 600; color: var(--ad-text-3, #a1a1a6); margin-left: 2px; }
.com-kpi .l { font-size: 12.5px; color: var(--ad-text-2, #6e6e73); font-weight: 500; }
.com-kpi .s { font-size: 11px; color: var(--ad-text-3, #a1a1a6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.com-kpi::after { content: ''; position: absolute; right: -18px; top: -18px; width: 64px; height: 64px; border-radius: 50%; background: var(--com-kpi-tinte, rgba(10,132,255,.08)); }
.com-kpi--total { --com-kpi-tinte: rgba(232,135,50,.14); }
.com-kpi--mes { --com-kpi-tinte: rgba(10,132,255,.10); }
.com-kpi--ultima { --com-kpi-tinte: rgba(52,199,89,.12); }
.com-kpi--sel { --com-kpi-tinte: rgba(94,92,230,.12); }

/* ── Rejilla y tarjetas ───────────────────────────────────────────────────── */
.com-grid { display: grid; grid-template-columns: minmax(340px, 5fr) minmax(380px, 7fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .com-grid { grid-template-columns: 1fr; } }
.com-card { background: var(--ad-card, #fff); border: 1px solid var(--ad-border, rgba(0,0,0,.08)); border-radius: var(--ad-r-card, 18px); box-shadow: var(--ad-sh, 0 1px 3px rgba(0,0,0,.05)); padding: 16px 18px; }
.com-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.com-h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ad-text, #1d1d1f); }
.com-seg { display: inline-flex; background: color-mix(in srgb, var(--ad-text, #1d1d1f) 6%, transparent); border-radius: var(--ad-r-pill, 980px); padding: 3px; gap: 2px; }
#comunicacionesSection .com-seg-btn { border: 0 !important; background: transparent !important; color: var(--ad-text-2, #6e6e73) !important; font-weight: 600 !important; font-size: 13px !important; padding: 7px 14px !important; border-radius: var(--ad-r-pill, 980px) !important; cursor: pointer !important; transition: all .15s !important; }
#comunicacionesSection .com-seg-btn.active { background: var(--ad-card, #fff) !important; color: var(--ad-text, #1d1d1f) !important; box-shadow: 0 1px 3px rgba(0,0,0,.12) !important; }
.com-count { font-size: 12px; font-weight: 600; color: #9a4a12; background: rgba(232,135,50,.14); padding: 4px 10px; border-radius: var(--ad-r-pill, 980px); white-space: nowrap; }
.com-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.com-buscar { display: flex; align-items: center; gap: 8px; background: var(--ad-card, #fff); border: 1px solid var(--ad-border-2, rgba(0,0,0,.14)); border-radius: var(--ad-r-pill, 980px); padding: 0 14px; height: 38px; }
.com-buscar:focus-within { border-color: var(--ad-accent, #e88732); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ad-accent, #e88732) 22%, transparent); }
.com-buscar span { color: var(--ad-text-3, #a1a1a6); font-size: 14px; }
.com-buscar input { flex: 1; border: 0; background: transparent; outline: none; font: inherit; font-size: 13.5px; color: var(--ad-text, #1d1d1f); min-width: 0; }
.com-buscar input::placeholder { color: var(--ad-text-3, #a1a1a6); }
.com-input { width: 100%; box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--ad-border-2, rgba(0,0,0,.14)); border-radius: var(--ad-r-el, 12px); font: inherit; font-size: 14px; background: var(--ad-card, #fff); color: var(--ad-text, #1d1d1f); }
.com-input:focus { outline: none; border-color: var(--ad-accent, #e88732); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ad-accent, #e88732) 22%, transparent); }
.com-atajos { display: flex; flex-wrap: wrap; gap: 6px; }
#comunicacionesSection .com-chip-btn { border: 1px solid var(--ad-border-2, rgba(0,0,0,.14)) !important; background: var(--ad-card, #fff) !important; color: var(--ad-text-2, #6e6e73) !important; border-radius: var(--ad-r-pill, 980px) !important; padding: 5px 11px !important; font-size: 12px !important; font-weight: 600 !important; cursor: pointer !important; }
#comunicacionesSection .com-chip-btn:hover { border-color: var(--ad-accent, #e88732) !important; color: var(--ad-accent, #e88732) !important; }
#comunicacionesSection .com-chip-btn--equipo { background: #eaf3ff !important; border-color: #bcd8ff !important; color: #0a5fcc !important; }

/* Lista de destinatarios (casilla nativa visible: anula el ocultado global de style.css) */
.com-lista { max-height: 520px; overflow: auto; border: 1px solid var(--ad-border, rgba(0,0,0,.08)); border-radius: 14px; display: flex; flex-direction: column; }
.com-dest { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--ad-border, rgba(0,0,0,.06)); cursor: pointer; transition: background .12s; }
.com-dest:last-child { border-bottom: 0; }
.com-dest:hover { background: color-mix(in srgb, var(--ad-text, #1d1d1f) 4%, transparent); }
.com-dest.is-sel { background: color-mix(in srgb, var(--ad-accent, #e88732) 10%, var(--ad-card, #fff)); }
.com-dest.is-bloq { opacity: .55; cursor: not-allowed; }
#comunicacionesSection .com-dest input[type="checkbox"] { opacity: 1 !important; position: static !important; width: 17px !important; height: 17px !important; margin: 0 !important; flex: none !important; accent-color: var(--ad-accent, #e88732) !important; cursor: pointer !important; appearance: auto !important; -webkit-appearance: auto !important; }
.com-dest-avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #e88732, #f6b26b); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.com-dest-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.com-dest-nombre { font-weight: 600; font-size: 13.5px; color: var(--ad-text, #1d1d1f); }
.com-dest-meta { font-size: 12px; color: var(--ad-text-2, #6e6e73); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.com-dest-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.com-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: var(--ad-r-pill, 980px); background: #e2e8f0; color: #334155; white-space: nowrap; }
.com-tag--gris { background: #eef0f3; color: #6e6e73; }
.com-tag--amb { background: #fef3c7; color: #92400e; }
.com-tag--ok { background: #dcfce7; color: #166534; }
.com-tag--err { background: #fee2e2; color: #991b1b; }
.com-tag--thor { background: #dbeafe; color: #1e40af; }
.com-tag--pt { background: #fef3c7; color: #92400e; }
.com-vacio { padding: 22px; text-align: center; color: var(--ad-text-2, #6e6e73); font-size: 13.5px; }
.com-vacio--error { color: #b91c1c; }

/* Mensaje */
.com-label { display: block; font-size: 11px; font-weight: 700; color: var(--ad-text-2, #6e6e73); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.com-label:first-child { margin-top: 0; }
.com-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border: 1px solid var(--ad-border-2, rgba(0,0,0,.14)); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--ad-card-2, #fbfbfd); }
#comunicacionesSection .com-toolbar button { border: 1px solid transparent !important; background: transparent !important; padding: 5px 9px !important; border-radius: 8px !important; font-size: 12.5px !important; cursor: pointer !important; color: var(--ad-text, #1d1d1f) !important; }
#comunicacionesSection .com-toolbar button:hover { background: var(--ad-card, #fff) !important; border-color: var(--ad-border-2, rgba(0,0,0,.14)) !important; }
.com-toolbar-sep { width: 1px; background: var(--ad-border-2, rgba(0,0,0,.14)); margin: 3px 4px; }
.com-editor { min-height: 220px; max-height: 480px; overflow: auto; padding: 12px 14px; border: 1px solid var(--ad-border-2, rgba(0,0,0,.14)); border-radius: 0 0 12px 12px; font-size: 14.5px; line-height: 1.55; color: var(--ad-text, #1d1d1f); background: var(--ad-card, #fff); }
.com-editor:focus { outline: none; border-color: var(--ad-accent, #e88732); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ad-accent, #e88732) 22%, transparent); }
.com-editor:empty::before { content: attr(data-placeholder); color: var(--ad-text-3, #a1a1a6); }
.com-editor h3 { font-size: 16px; margin: 10px 0 6px; }
.com-editor ul, .com-editor ol { margin: 6px 0 6px 22px; }
.com-editor a { color: var(--ad-accent, #e88732); }

/* Canales: interruptores estilo iOS (el input sigue oculto por style.css; el estado lo pinta la pista) */
.com-opciones { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 14px 0 12px; }
.com-switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 500; color: var(--ad-text, #1d1d1f); cursor: pointer; user-select: none; position: relative; }
.com-switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.com-switch-track { width: 42px; height: 26px; border-radius: 26px; background: #d1d5db; position: relative; transition: background .18s ease; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.04); }
.com-switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .18s ease; }
.com-switch input:checked + .com-switch-track { background: var(--ad-green, #34c759); }
.com-switch input:checked + .com-switch-track::after { transform: translateX(16px); }
.com-switch input:focus-visible + .com-switch-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ad-accent, #e88732) 30%, transparent); }
.com-switch--forzar input:checked + .com-switch-track { background: #ff9f0a; }
.com-switch-txt { line-height: 1.2; }
.com-switch-txt small { display: block; font-size: 11.5px; font-weight: 400; color: var(--ad-text-2, #6e6e73); }
.com-acciones { display: flex; justify-content: flex-end; gap: 8px; }
.com-resultado { margin-top: 12px; }
.com-resultado.hidden { display: none; }
.com-res { padding: 10px 12px; border-radius: 12px; font-size: 13.5px; }
.com-res--ok { background: #dcfce7; color: #166534; }
.com-res--error { background: #fee2e2; color: #991b1b; }

/* Histórico */
.com-historial { overflow: auto; }
.com-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.com-tabla th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ad-text-2, #6e6e73); padding: 8px; border-bottom: 1px solid var(--ad-border, rgba(0,0,0,.08)); white-space: nowrap; }
.com-tabla td { padding: 9px 8px; border-bottom: 1px solid var(--ad-border, rgba(0,0,0,.06)); vertical-align: top; color: var(--ad-text, #1d1d1f); }
.com-tabla tbody tr:hover td { background: color-mix(in srgb, var(--ad-text, #1d1d1f) 3%, transparent); }
.com-td-asunto { font-weight: 600; max-width: 360px; }
.com-td-acc { white-space: nowrap; }
#comunicacionesSection .com-link { border: 0 !important; background: none !important; color: var(--ad-accent, #e88732) !important; font-weight: 600 !important; cursor: pointer !important; padding: 0 !important; font-size: 13px !important; }
#comunicacionesSection .com-link:hover { text-decoration: underline !important; }
.com-muted { color: var(--ad-text-2, #6e6e73); }
.small { font-size: 12px; }

/* Modal de previsualización / detalle */
.com-overlay { position: fixed; inset: 0; z-index: 10040; background: rgba(0,0,0,.38); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 16px; font-family: var(--ad-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif); }
.com-overlay.hidden { display: none; }
.com-modal { background: var(--ad-card, #fff); color: var(--ad-text, #1d1d1f); border-radius: 22px; width: 100%; max-width: 760px; max-height: 88vh; overflow: auto; box-shadow: 0 24px 70px rgba(0,0,0,.28); animation: comModalIn .18s ease-out; }
@keyframes comModalIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.com-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--ad-border, rgba(0,0,0,.08)); position: sticky; top: 0; background: inherit; z-index: 1; }
.com-modal-body { padding: 16px; }
.com-chip { background: rgba(232,135,50,.14); color: #9a4a12; border-radius: var(--ad-r-pill, 980px); padding: 4px 10px; font-size: 12px; font-weight: 700; }
#comunicacionesSection .com-x, .com-x { border: 0 !important; background: transparent !important; width: 30px; height: 30px; border-radius: 50%; font-size: 15px; cursor: pointer; color: var(--ad-text-2, #6e6e73); display: inline-flex; align-items: center; justify-content: center; }
.com-x:hover { background: color-mix(in srgb, var(--ad-text, #1d1d1f) 8%, transparent) !important; }
.com-preview-mail { border: 1px solid var(--ad-border, rgba(0,0,0,.08)); border-radius: 14px; overflow: hidden; }
.com-preview-top { background: #1d1d1f; color: #fff; padding: 10px 16px; font-size: 13px; }
.com-preview-body { padding: 16px 18px; font-size: 15px; line-height: 1.55; }
.com-preview-body h2 { margin: 0 0 12px; font-size: 19px; letter-spacing: -.01em; }

/* ── Aviso al entrar (comunicaciones pendientes) ─────────────────────────── */
.com-aviso-overlay { position: fixed; inset: 0; z-index: 10060; background: rgba(0,0,0,.42); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 16px; font-family: var(--ad-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif); }
.com-aviso-modal { background: var(--ad-card, #fff); color: var(--ad-text, #1d1d1f); border-radius: 22px; width: 100%; max-width: 640px; max-height: 86vh; overflow: auto; box-shadow: 0 24px 70px rgba(0,0,0,.3); padding: 20px 24px; animation: comModalIn .18s ease-out; }
.com-aviso-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.com-aviso-titulo { margin: 0 0 12px; font-size: 20px; line-height: 1.25; font-weight: 700; letter-spacing: -.015em; }
.com-aviso-cuerpo { font-size: 15px; line-height: 1.55; }
.com-aviso-cuerpo p { margin: 0 0 10px; }
.com-aviso-cuerpo ul, .com-aviso-cuerpo ol { margin: 0 0 10px 22px; }
.com-aviso-pie { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--ad-border, rgba(0,0,0,.08)); }
.com-aviso-modal .com-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 980px; border: 1px solid transparent; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.com-aviso-modal .com-btn--pri { background: linear-gradient(135deg, #f0974a 0%, var(--ad-accent, #e88732) 100%); color: #fff; box-shadow: 0 4px 14px rgba(232,135,50,.28); }

/* ── Modo oscuro ─────────────────────────────────────────────────────────── */
[data-theme="dark"] .com-card, [data-theme="dark"] .com-kpi, [data-theme="dark"] .com-modal, [data-theme="dark"] .com-aviso-modal, [data-theme="dark"] .com-buscar, [data-theme="dark"] .com-input, [data-theme="dark"] .com-editor, [data-theme="dark"] .com-toolbar { background: var(--ad-card, #1c1c1e); border-color: var(--ad-border, rgba(255,255,255,.10)); color: var(--ad-text, #f5f5f7); }
[data-theme="dark"] .com-dest.is-sel { background: rgba(232,135,50,.18); }
[data-theme="dark"] .com-tag--thor { background: rgba(59,130,246,.2); color: #93c5fd; }
[data-theme="dark"] .com-tag--pt, [data-theme="dark"] .com-tag--amb { background: rgba(245,158,11,.2); color: #fcd34d; }
[data-theme="dark"] .com-tag--ok { background: rgba(34,197,94,.2); color: #86efac; }
[data-theme="dark"] .com-tag--err { background: rgba(239,68,68,.2); color: #fca5a5; }
[data-theme="dark"] .com-res--ok { background: rgba(34,197,94,.15); color: #86efac; }
[data-theme="dark"] .com-res--error { background: rgba(239,68,68,.15); color: #fca5a5; }
