/* ============================================
   Centro de Mando — Sofía / Ventas / Sistema / Anuncios
   Marca Almas en Ruta (navy + gold). Aditivo, no pisa nada.
   ============================================ */

/* ---- Estados ---- */
.cc-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-md); padding: var(--space-3xl) var(--space-lg);
  color: var(--text-muted); font-size: var(--text-sm);
}
.cc-spinner {
  width: 34px; height: 34px; border: 3px solid var(--color-border);
  border-top-color: var(--color-primary); border-radius: 50%;
  animation: ccSpin .8s linear infinite;
}
@keyframes ccSpin { to { transform: rotate(360deg); } }

.cc-errbox { text-align: center; padding: var(--space-2xl) var(--space-lg); }
.cc-err-ico { color: var(--color-error); font-size: 2rem; margin-bottom: var(--space-sm); }
.cc-errbox h3 { color: var(--text-primary); margin-bottom: var(--space-xs); }
.cc-errbox p { color: var(--text-muted); margin-bottom: var(--space-lg); }
.cc-err { color: var(--color-error); font-size: var(--text-sm); min-height: 18px; margin-top: var(--space-xs); }

/* ---- Tarjeta de conexión ---- */
.cc-connect { max-width: 460px; margin: var(--space-xl) auto; }
.cc-connect-icon {
  width: 56px; height: 56px; border-radius: var(--radius-md);
  background: var(--bg-surface-alt); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin-bottom: var(--space-md);
}
.cc-connect-sub { color: var(--text-secondary); font-size: var(--text-sm); margin-bottom: var(--space-lg); line-height: 1.5; }
.cc-label { display: block; font-size: var(--text-xs); font-weight: 700; color: var(--text-primary); margin: var(--space-md) 0 var(--space-xs); }
.cc-input { width: 100%; }

/* ---- Barra de conexión ---- */
.cc-conn-bar {
  display: flex; align-items: center; gap: var(--space-sm);
  font-size: var(--text-xs); color: var(--text-muted);
  margin-bottom: var(--space-lg);
}
.cc-conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--color-success); box-shadow: 0 0 8px rgba(22,101,52,.5); flex: none; }
.cc-conn-bar b { color: var(--text-secondary); }
.cc-reconf-link {
  background: none; border: none; color: var(--color-primary); cursor: pointer;
  font-size: var(--text-xs); font-weight: 600; margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px; padding: 6px;
  border-radius: var(--radius-sm); transition: background var(--transition-fast);
}
.cc-reconf-link:hover { background: var(--bg-surface); }
.cc-reconf-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ---- Conversaciones ---- */
.cc-chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: var(--space-lg); min-height: 60vh; }
.cc-chat-list { display: flex; flex-direction: column; gap: var(--space-xs); overflow-y: auto; max-height: 70vh; padding-right: 4px; }
.cc-chat-item {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  background: var(--bg-card); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: var(--space-md);
  cursor: pointer; min-height: 60px; transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.cc-chat-item:hover { border-color: var(--color-primary-light); box-shadow: var(--shadow-sm); }
.cc-chat-item.active { border-color: var(--color-primary); box-shadow: var(--shadow-glow); }
.cc-chat-item:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.cc-chat-name { font-weight: 700; font-size: var(--text-sm); color: var(--text-primary); }
.cc-chat-prev { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cc-chat-view { background: var(--bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-sm); }
.cc-chat-head { padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--color-border); font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); color: var(--color-secondary); }
.cc-chat-msgs { flex: 1; overflow-y: auto; padding: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-sm); max-height: 60vh; }
.cc-chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); padding: var(--space-3xl); }
.cc-bubble { max-width: 78%; padding: var(--space-sm) var(--space-md); border-radius: var(--radius-md); font-size: var(--text-sm); line-height: 1.5; white-space: pre-wrap; }
.cc-bubble-t { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }
.cc-bubble.cli { align-self: flex-start; background: var(--bg-surface); border: 1px solid var(--color-border); color: var(--text-primary); border-bottom-left-radius: 4px; }
.cc-bubble.sof { align-self: flex-end; background: var(--bg-surface-alt); border: 1px solid var(--color-primary-light); color: var(--text-primary); border-bottom-right-radius: 4px; }

/* ---- Pipeline ---- */
.cc-pipe-row { display: flex; align-items: center; gap: var(--space-md); margin: var(--space-sm) 0; }
.cc-pipe-nm { width: 150px; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.cc-pipe-track { flex: 1; height: 12px; background: var(--bg-surface); border-radius: var(--radius-full); overflow: hidden; }
.cc-pipe-fill { height: 100%; border-radius: var(--radius-full); transition: width var(--transition-slow); }
.cc-pipe-ct { width: 32px; text-align: right; font-weight: 800; color: var(--text-primary); }

/* ---- Tabla ---- */
.cc-table-wrap { overflow-x: auto; }
.cc-table { width: 100%; border-collapse: collapse; }
.cc-table th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--text-muted); padding: var(--space-sm) var(--space-md); border-bottom: 2px solid var(--color-border); }
.cc-table td { padding: var(--space-md); border-bottom: 1px solid var(--color-border); font-size: var(--text-sm); color: var(--text-primary); }
.cc-table tr:hover td { background: var(--bg-surface-alt); }
.cc-tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-weight: 700; padding: 3px 10px; border-radius: var(--radius-full); }
.cc-tag.CALIFICADO { background: var(--color-success-light); color: var(--color-success); }
.cc-tag.FILTRO { background: var(--color-warning-light); color: var(--color-warning); }
.cc-tag.PAGO_REPORTADO, .cc-tag.PAGO { background: rgba(74,111,165,.15); color: var(--color-accent); }
.cc-score { font-weight: 800; color: var(--color-primary); }
.cc-mono { font-family: 'Courier New', monospace; color: var(--text-muted); font-size: var(--text-xs); }

/* ---- Luces Hue ---- */
.cc-hue-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-md); }
.cc-hue-card { display: flex; align-items: center; gap: var(--space-md); background: var(--bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-md); }
.cc-hue-bulb { width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex: none; border: 1px solid var(--color-border); color: var(--text-muted); }
.cc-hue-card.on .cc-hue-bulb { background: var(--color-warning-light); border-color: var(--color-warning); color: var(--color-warning); }
.cc-hue-info { min-width: 0; }
.cc-hue-nm { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-hue-st { font-size: var(--text-xs); color: var(--text-muted); }

/* ---- Anuncios (5 posturas) ---- */
.cc-postura-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-md); }
.cc-postura { background: var(--bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-lg); text-align: center; }
.cc-postura-ico { width: 46px; height: 46px; margin: 0 auto var(--space-sm); border-radius: var(--radius-full); background: var(--bg-surface-alt); color: var(--color-primary); display: flex; align-items: center; justify-content: center; }
.cc-postura-nm { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); color: var(--color-secondary); }
.cc-postura-d { font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
.cc-code { background: var(--color-secondary); color: #E4C07A; padding: var(--space-md); border-radius: var(--radius-md); font-family: 'Courier New', monospace; font-size: var(--text-xs); overflow-x: auto; margin: var(--space-md) 0; white-space: pre; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .cc-chat-layout { grid-template-columns: 1fr; }
  .cc-chat-list { max-height: 220px; }
  .cc-pipe-nm { width: 110px; }
}

/* ---- Chat: borrar mensaje + composer ---- */
.cc-bubble { position: relative; }
.cc-msg-del {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px;
  border-radius: 50%; border: 1px solid var(--color-border); background: var(--bg-card);
  color: var(--color-error); cursor: pointer; display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm); padding: 0;
}
.cc-msg-del svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.cc-bubble:hover .cc-msg-del { display: flex; }
.cc-msg-del:focus-visible { outline: 2px solid var(--color-error); outline-offset: 1px; display: flex; }

.cc-composer { display: flex; gap: var(--space-sm); padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--color-border); }
.cc-composer-input { flex: 1; background: var(--bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-full); padding: 10px 16px; font-family: inherit; font-size: var(--text-sm); color: var(--text-primary); }
.cc-composer-input:focus { outline: none; border-color: var(--color-primary); }
.cc-composer-send { flex: none; width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--color-primary); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background var(--transition-base); }
.cc-composer-send:hover { background: var(--color-primary-dark); }
.cc-composer-send:disabled { opacity: .5; cursor: not-allowed; }
.cc-composer-send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; }
.cc-composer-status { font-size: var(--text-xs); color: var(--text-muted); padding: 0 var(--space-lg) var(--space-sm); min-height: 16px; }
.cc-composer-status.err { color: var(--color-error); }

/* ---- Registro (auditoría) ---- */
.cc-log-filters { display: flex; gap: var(--space-sm); margin-bottom: var(--space-md); }
.cc-log-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-card); border: 1px solid var(--color-border); color: var(--text-secondary); border-radius: var(--radius-full); padding: 7px 16px; font-size: var(--text-sm); font-weight: 600; cursor: pointer; transition: all var(--transition-base); }
.cc-log-chip svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.cc-log-chip:hover { border-color: var(--color-primary-light); }
.cc-log-chip.active { background: var(--color-secondary); color: #fff; border-color: var(--color-secondary); }
.cc-log-card { padding: 0; overflow: hidden; }
.cc-log-row { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--color-border); }
.cc-log-row:last-child { border-bottom: none; }
.cc-log-ico { width: 38px; height: 38px; flex: none; border-radius: var(--radius-md); background: var(--bg-surface-alt); color: var(--color-primary); display: flex; align-items: center; justify-content: center; }
.cc-log-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.cc-log-main { flex: 1; min-width: 0; }
.cc-log-act { font-weight: 700; font-size: var(--text-sm); color: var(--text-primary); }
.cc-log-d { font-size: var(--text-xs); color: var(--text-muted); }
.cc-log-meta { text-align: right; flex: none; display: flex; flex-direction: column; gap: 2px; }
.cc-log-who { font-size: var(--text-xs); font-weight: 600; color: var(--color-secondary); display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; }
.cc-log-who svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.cc-log-t { font-size: 0.75rem; color: var(--text-muted); }

/* ---- Grupos de viaje (Config) + insignias (Viajeros) ---- */
.trip-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; font-weight: 700; padding: 2px 9px; border-radius: var(--radius-full); background: color-mix(in srgb, var(--tc) 14%, transparent); color: var(--tc); border: 1px solid color-mix(in srgb, var(--tc) 45%, transparent); vertical-align: middle; }
.trip-badge svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.trip-edit-row { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.trip-color { width: 44px; height: 40px; flex: none; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: none; cursor: pointer; padding: 2px; }
.trip-name { flex: 1; }
.trip-del { flex: none; width: 40px; height: 40px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--color-error); cursor: pointer; }
.trip-del svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.group-row { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md) 0; border-bottom: 1px solid var(--bg-surface); }
.group-row-name { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--text-sm); color: var(--text-primary); }
.group-row-name svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.group-row-user { color: var(--text-muted); font-weight: 400; font-size: var(--text-xs); }
.group-select { max-width: 220px; }
.grp-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--tc); border: 1px solid rgba(0,0,0,.1); }
.grp-dot--none { background: transparent; border: 1px dashed var(--color-border); }

/* ---- Accesibilidad: respeta reduce-motion ---- */
@media (prefers-reduced-motion: reduce) {
  .cc-spinner { animation-duration: 1.6s; }
  .cc-pipe-fill, .cc-chat-item, .cc-reconf-link, .cc-composer-send, .cc-log-chip { transition: none; }
}
