/* ============================================================
   SMACHIL POS — Comunicación Interna (Estilos)
   Phase 1 MVP — Botón flotante, panel lateral, composer, detalle
   Usa variables de css/vars.css
   ============================================================ */

/* ── Z-INDEX REFERENCE ──
   800   #com-btn-flotante (botón flotante)
   840   #com-overlay (backdrop del panel)
   850   #com-panel (panel lateral)
   10000 #com-urgente-overlay (alerta urgente, sobre todo)
── */

/* ── Botón flotante ── */
#com-btn-flotante {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text);
  border: none;
  font-size: 24px;
  cursor: pointer;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  -webkit-tap-highlight-color: transparent;
}
#com-btn-flotante:active { transform: scale(0.93); }

#com-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}
#com-badge.visible { display: flex; }
@keyframes com-badge-bounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}
#com-badge.bounce {
  animation: com-badge-bounce 0.35s ease;
}

/* ── Overlay (backdrop del panel) ── */
#com-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 20, 25, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 840;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#com-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Panel lateral ── */
#com-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--surface);
  z-index: 850;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  font-family: 'DM Sans', sans-serif;
}
#com-panel.open { transform: translateX(0); }

/* Header del panel */
.com-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.com-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.com-header-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  line-height: 1;
}

/* Tabs */
.com-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.com-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}
.com-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Área de contenido (scrollable) */
.com-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Lista de hilos ── */
.com-hilo-item {
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.com-hilo-item:hover  { background: var(--surface2); }
.com-hilo-item:active { background: var(--surface2); }

/* Borde lateral por tipo de hilo */
.com-hilo-item.com-tipo-urgente    { border-left-color: var(--red); }
.com-hilo-item.com-tipo-comunicado { border-left-color: #3B82F6; }
.com-hilo-item.com-tipo-sistema    { border-left-color: var(--muted); }

.com-hilo-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.com-hilo-icon.urgente    { background: #FEE2E2; }
.com-hilo-icon.comunicado { background: #DBEAFE; }
.com-hilo-icon.sistema    { background: #E5E7EB; }

.com-hilo-body {
  flex: 1;
  min-width: 0;
}
.com-hilo-titulo {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.com-hilo-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.com-hilo-estado {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
  margin-top: 4px;
}
.com-estado-resuelto,
.com-estado-atendido    { background: #D1FAE5; color: #065F46; }
.com-estado-pendiente   { background: #FEE2E2; color: #991B1B; }
.com-estado-archivado   { background: #E5E7EB; color: #6B7280; }
.com-estado-activo      { background: #DBEAFE; color: #1E40AF; }

/* ── Unread indicator ── */
.com-hilo-item.com-hilo-unread {
  background: rgba(var(--accent-rgb, 237, 196, 101), 0.08);
}
.com-hilo-item.com-hilo-unread .com-hilo-titulo {
  font-weight: 800;
}
.com-unread-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent2, var(--accent));
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Botón nuevo */
.com-btn-nuevo {
  margin: 12px 20px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  width: calc(100% - 40px);
  flex-shrink: 0;
}
.com-btn-nuevo:active { transform: scale(0.97); }

/* ── Composer (dentro del panel) ── */
.com-composer {
  padding: 0;
}
.com-composer-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.com-composer-section:last-of-type { border-bottom: none; }
.com-composer label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Banner de advertencia urgente dentro del composer */
.com-urgente-warning {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  color: #991B1B;
  margin-top: 8px;
  line-height: 1.4;
}

.com-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.com-chip {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.com-chip.selected {
  background: var(--accent);
  border-color: var(--accent2);
  font-weight: 700;
}

.com-type-btns {
  display: flex;
  gap: 8px;
}
.com-type-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s, border-color 0.12s;
}
.com-type-btn.selected {
  border-color: var(--accent2);
  background: var(--accent);
}
.com-type-btn.urgente-sel {
  border-color: var(--red);
  background: #FEE2E2;
  color: #991B1B;
}

.com-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  margin-top: 6px;
  outline: none;
  color: var(--text);
  background: var(--surface);
  box-sizing: border-box;
}
.com-input:focus { border-color: var(--accent); }

.com-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  margin-top: 6px;
  resize: vertical;
  min-height: 60px;
  outline: none;
  color: var(--text);
  background: var(--surface);
  box-sizing: border-box;
}
.com-textarea:focus { border-color: var(--accent); }

.com-composer-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.com-composer-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.com-btn-cancelar { background: var(--surface2); color: var(--muted); }
.com-btn-enviar   { background: var(--accent); color: var(--text); }
.com-btn-enviar:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Detail view (dentro del panel) ── */
.com-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.com-detail-back {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  color: var(--muted);
  line-height: 1;
}
.com-detail-titulo {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.com-detail-resolver {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.com-detail-resolver:active { transform: scale(0.95); }

.com-detail-secondary {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.com-detail-secondary:active { transform: scale(0.95); }

.com-detail-info {
  padding: 10px 20px;
  background: var(--surface2);
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.com-detail-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

.com-msg {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
}
.com-msg.com-msg-propio { align-items: flex-end; }
.com-msg.com-msg-ajeno  { align-items: flex-start; }

.com-msg-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  position: relative;
}
.com-msg-ajeno .com-msg-bubble {
  background: var(--surface2);
  border-top-left-radius: 3px;
}
.com-msg-propio .com-msg-bubble {
  background: rgba(253, 200, 15, 0.15);
  border-top-right-radius: 3px;
}

.com-msg-autor {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent2);
  margin-bottom: 2px;
}
.com-msg-propio .com-msg-autor { color: var(--muted); }

.com-msg-contenido {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}
.com-msg-time {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
}

.com-detail-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.com-detail-input-area input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  color: var(--text);
  background: var(--surface);
  box-sizing: border-box;
}
.com-detail-input-area input:focus { border-color: var(--accent); }
.com-detail-input-area button {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}

/* ── Empty state ── */
.com-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ── Overlay URGENTE (z-index máximo, sobre todo) ── */
#com-urgente-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(153, 27, 27, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#com-urgente-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.com-urgente-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 32px 32px;
  max-width: 360px;
  width: calc(100% - 40px);
  text-align: center;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
  animation: com-urgente-pulse 0.3s ease;
}
@keyframes com-urgente-pulse {
  0%   { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

.com-urgente-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.com-urgente-label {
  font-size: 22px;
  font-weight: 800;
  color: #991B1B;
  letter-spacing: 2px;
  margin-bottom: 16px;
  font-family: 'DM Sans', sans-serif;
}
.com-urgente-origen {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  font-family: 'DM Sans', sans-serif;
}
.com-urgente-texto {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 24px;
  word-break: break-word;
  font-family: 'DM Sans', sans-serif;
}
.com-urgente-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.com-urgente-ack {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--green);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  letter-spacing: 0.5px;
}
.com-urgente-ack:active { transform: scale(0.96); }
.com-urgente-ack:disabled { opacity: 0.6; cursor: not-allowed; }

.com-urgente-reply {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  letter-spacing: 0.4px;
}
.com-urgente-reply:active { transform: scale(0.96); }
.com-urgente-reply:disabled { opacity: 0.6; cursor: not-allowed; }

.com-urgente-dismiss {
  padding: 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  min-width: 72px;
}
.com-urgente-dismiss:active { transform: scale(0.96); }

/* ── Responsive ── */
@media (max-width: 600px) {
  #com-panel {
    width: 100vw;
  }
  #com-btn-flotante {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}
