/* styles.css - Theme: Vibrant Dark Paper (Purple Edition V2.0 + Heartbeat & Features 1,3,4,5) */
:root {
  --bg-dark: #0a0b10;
  --bg-glow: #24123f;
  --bg-paper: #141622;
  --bg-card: #1e2133;
  --bg-input: #272a40;
  --bg-hover: #323652;
  
  --border-purple: rgba(168, 85, 247, 0.45);
  --border-color: rgba(255, 255, 255, 0.08);
  --accent-purple-glow: rgba(168, 85, 247, 0.4);
  
  --accent-purple: #a855f7;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-emerald: #00ff87;
  --accent-lime: #84cc16;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --danger: #f43f5e;
  
  --bubble-out: #7e22ce;
  --bubble-in: #1e2133;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

body {
  background-color: var(--bg-dark);
  background-image: radial-gradient(circle at 50% -20%, var(--bg-glow), var(--bg-dark) 70%);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.justify-center { justify-content: center; }

.accent-purple { color: var(--accent-purple) !important; }
.accent-cyan { color: var(--accent-cyan) !important; }
.accent-pink { color: var(--accent-pink) !important; }
.accent-emerald { color: var(--accent-emerald) !important; }
.accent-lime { color: var(--accent-lime) !important; }
.accent-rose { color: var(--accent-rose) !important; }
.accent-bg-emerald { background: var(--accent-emerald) !important; color: #000 !important; font-weight: 800; }

/* Layout Autenticación */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  padding: 1rem;
}

.auth-card {
  background: var(--bg-paper);
  padding: 2.5rem;
  border-radius: 24px;
  border: 1px solid var(--border-purple);
  width: 100%;
  max-width: 420px;
  box-shadow: 0 0 35px var(--accent-purple-glow);
}

.auth-header h2 {
  color: var(--accent-purple);
  font-size: 2.2rem;
  margin-bottom: 0.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.auth-header p {
  color: var(--text-muted);
  margin-bottom: 1.8rem;
  font-size: 0.95rem;
}

.input-group {
  margin-bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.input-group input, .input-group textarea, .input-group select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: white;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus, .input-group textarea:focus, .input-group select:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 10px var(--accent-purple-glow);
}

.code-editor-input {
  font-family: 'Consolas', 'Courier New', monospace !important;
  font-size: 0.85rem !important;
  background: #0d0e15 !important;
  color: #38bdf8 !important;
  line-height: 1.4;
  white-space: pre;
}

/* Botones */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  color: white;
  font-weight: 700;
  padding: 0.85rem 1.2rem;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.1s, opacity 0.2s;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.btn-primary:hover { opacity: 0.95; transform: translateY(-1px); }
.btn-primary.danger { background: var(--danger); box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3); }

.btn-secondary {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: white;
  padding: 0.85rem 1.2rem;
  border-radius: 12px;
  cursor: pointer;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.icon-btn:hover { color: white; background: var(--bg-hover); }

.btn-primary-sm { background: var(--accent-purple); border: none; color: white; font-size: 0.8rem; padding: 0.45rem 0.85rem; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-danger-sm { background: var(--danger); border: none; color: white; font-size: 0.8rem; padding: 0.45rem 0.85rem; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-warning-sm { background: var(--accent-amber); border: none; color: #000; font-size: 0.8rem; padding: 0.45rem 0.85rem; border-radius: 8px; cursor: pointer; font-weight: 700; }
.btn-secondary-sm { background: var(--bg-hover); border: 1px solid var(--border-color); color: white; font-size: 0.8rem; padding: 0.45rem 0.85rem; border-radius: 8px; cursor: pointer; }

/* Avatares */
.avatar-frame {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  overflow: hidden;
  border: 1px solid var(--border-purple);
}
.avatar-frame img { width: 100%; height: 100%; object-fit: cover; }
.avatar-frame.large { width: 68px; height: 68px; border-radius: 20px; font-size: 1.5rem; }
.avatar-frame.xl { width: 96px; height: 96px; border-radius: 28px; font-size: 2.2rem; }

/* Layout App */
.app-layout { display: flex; height: 100vh; position: relative; }
body.auth-mode .app-layout { display: none; }
body.app-mode .auth-container { display: none; }

.sidebar-left {
  width: 330px;
  background: var(--bg-paper);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
}

.user-profile-bar {
  padding: 1.1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-info { display: flex; align-items: center; gap: 0.8rem; font-weight: 600; }
.user-text-details { display: flex; flex-direction: column; }
.status-online-dot { font-size: 0.72rem; color: var(--accent-emerald); font-weight: 700; }
.profile-actions { display: flex; gap: 0.3rem; }

.channels-section { padding: 1rem; flex: 1; overflow-y: auto; }
.section-title-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.section-title-bar h3 { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 800; }
.paper-divider { border: 0; border-top: 1px solid var(--border-color); margin: 1.2rem 0; }

.chats-list { display: flex; flex-direction: column; gap: 0.5rem; }
.chat-list-item {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  transition: background 0.2s, border-color 0.2s;
  border: 1px solid transparent;
}
.chat-list-item:hover, .chat-list-item.active {
  background: var(--bg-hover);
  border-color: var(--accent-purple);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.15);
}

/* Chat Central */
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg-dark); position: relative; }
.placeholder-screen { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; color: var(--text-muted); }
.hero-icon { font-size: 4.5rem; color: var(--accent-purple); margin-bottom: 1rem; filter: drop-shadow(0 0 15px var(--accent-purple-glow)); }
.chat-active-hidden { display: none !important; }

.chat-container { display: flex; flex-direction: column; height: 100%; }
.chat-header {
  padding: 1rem 1.5rem;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header-left { display: flex; align-items: center; gap: 0.9rem; }
.status-indicator { font-size: 0.8rem; color: var(--accent-emerald); font-weight: 600; }
.sub-header-status { display: flex; align-items: center; gap: 0.6rem; }
.badge-p2p-off { font-size: 0.68rem; background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); border: 1px solid var(--accent-rose); padding: 2px 6px; border-radius: 6px; font-weight: 700; }
.call-controls { display: flex; gap: 0.5rem; }

.messages-area { flex: 1; padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.msg-wrapper { display: flex; flex-direction: column; max-width: 72%; }
.msg-wrapper.outgoing { align-self: flex-end; }
.msg-wrapper.incoming { align-self: flex-start; }

.msg-bubble {
  background: var(--bubble-in);
  padding: 0.85rem 1.1rem;
  border-radius: 18px;
  position: relative;
  color: var(--text-main);
  word-break: break-word;
  border: 1px solid var(--border-color);
}
.outgoing .msg-bubble {
  background: var(--bubble-out);
  border: none;
  box-shadow: 0 4px 15px rgba(126, 34, 206, 0.25);
}

.msg-meta-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Puntitos de Estado P2P Matrix (VERDE NEÓN DESTACADO) */
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  transition: all 0.2s ease;
}
.dot-gray { background-color: #94a3b8; }
.dot-blue {
  background-color: #06b6d4;
  box-shadow: 0 0 8px #06b6d4, 0 0 14px rgba(6, 182, 212, 0.5);
}
.dot-green {
  background-color: #00ff87 !important;
  box-shadow: 0 0 8px #00ff87, 0 0 16px rgba(0, 255, 135, 0.8) !important;
  width: 10px !important;
  height: 10px !important;
}
.dot-red {
  background-color: #f43f5e;
  box-shadow: 0 0 10px #f43f5e, 0 0 18px rgba(244, 63, 94, 0.6);
  animation: pulseRed 1.2s infinite;
}

@keyframes pulseRed {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

.btn-retry-p2p {
  background: var(--danger);
  border: none;
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.msg-actions-hover {
  position: absolute;
  right: 6px;
  top: -14px;
  background: var(--bg-paper);
  border-radius: 12px;
  display: none;
  padding: 2px 6px;
  border: 1px solid var(--border-purple);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.msg-bubble:hover .msg-actions-hover { display: flex; gap: 4px; }
.msg-action-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 2px; }
.msg-action-btn:hover { color: white; }

.deleted-msg-text { font-style: italic; color: var(--text-muted); font-size: 0.88rem; }
.deleted-tag-host { background: var(--danger); color: white; font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: bold; margin-left: 6px; }

/* FEATURE 3: Citas y Respuestas */
.reply-preview-bar {
  background: var(--bg-card);
  border-left: 4px solid var(--accent-purple);
  padding: 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
}
.quoted-msg-box {
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid var(--accent-cyan);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* FEATURE 1: Encuestas Interactivas (!poll) */
.poll-card-box {
  background: var(--bg-card);
  border: 1px solid var(--border-purple);
  border-radius: 14px;
  padding: 1rem;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 240px;
}
.poll-question { font-weight: 700; color: var(--text-main); font-size: 0.95rem; }
.poll-opt-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: white;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
.poll-bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: rgba(168, 85, 247, 0.25);
  transition: width 0.3s ease;
  z-index: 1;
}
.poll-opt-text { position: relative; z-index: 2; }
.poll-opt-pct { position: relative; z-index: 2; font-weight: bold; font-size: 0.78rem; color: var(--accent-cyan); }

/* FEATURE 5: Modo Anuncios (Solo Lectura) */
.announcement-badge {
  background: linear-gradient(135deg, var(--accent-rose), var(--accent-amber));
  color: black;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 800;
  margin-left: 6px;
}

.chat-input-area.disabled-announcement input {
  opacity: 0.5;
  cursor: not-allowed;
}

.call-log-card {
  align-self: center;
  background: rgba(30, 33, 51, 0.8);
  border: 1px solid var(--border-purple);
  padding: 0.6rem 1.2rem;
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.p2p-video-player { max-width: 100%; border-radius: 12px; margin-top: 0.5rem; border: 2px solid var(--accent-amber); }

/* Entrada de Texto */
.chat-input-area {
  padding: 1rem 1.5rem;
  background: var(--bg-paper);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  position: relative;
}
.input-tools { display: flex; gap: 0.3rem; }
#chat-text-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: white;
  padding: 0.85rem 1.2rem;
  border-radius: 25px;
  outline: none;
  font-size: 0.95rem;
}
#chat-text-input:focus { border-color: var(--accent-purple); }

.btn-send {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  color: white;
  padding: 0.85rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  box-shadow: 0 0 15px var(--accent-purple-glow);
}

.emoji-picker-container {
  position: absolute;
  bottom: 80px;
  left: 1rem;
  background: var(--bg-paper);
  border: 1px solid var(--border-purple);
  border-radius: 20px;
  width: 290px;
  padding: 1rem;
  box-shadow: 0 10px 35px rgba(0,0,0,0.7);
  z-index: 100;
}
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.5rem; max-height: 180px; overflow-y: auto; font-size: 1.3rem; text-align: center; cursor: pointer; }

/* Panel Derecho */
.sidebar-right {
  width: 290px;
  background: var(--bg-paper);
  border-left: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow-y: auto;
}
.details-card { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.details-icon { font-size: 3.5rem; color: var(--accent-purple); }

.user-controls-container { width: 100%; display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.5rem; }
.group-mgmt-container { width: 100%; text-align: left; }
.group-mgmt-container h4 { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 0.8rem; font-weight: 800; }
.sidebar-members-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 200px; overflow-y: auto; margin-bottom: 1rem; }
.member-row { display: flex; justify-content: space-between; align-items: center; background: var(--bg-card); padding: 0.55rem 0.85rem; border-radius: 10px; font-size: 0.85rem; }
.add-member-by-tag { display: flex; gap: 0.4rem; }
.add-member-by-tag input { flex: 1; background: var(--bg-input); border: 1px solid var(--border-color); color: white; padding: 0.45rem 0.7rem; border-radius: 8px; font-size: 0.85rem; outline: none; }

.chips-container { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.chip-item { background: var(--accent-purple); color: white; font-size: 0.8rem; padding: 0.25rem 0.65rem; border-radius: 12px; font-weight: 600; }

/* NC API Badges & Cards */
.badge-sis {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 800;
  margin-left: 4px;
}

.badge-high-level {
  background: linear-gradient(135deg, var(--accent-rose), #991b1b);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.4);
  margin-left: 4px;
}

.api-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-purple);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.api-card-header { display: flex; justify-content: space-between; align-items: center; }
.api-card-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(5, 5, 8, 0.88);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-card {
  background: var(--bg-paper);
  padding: 2.2rem;
  border-radius: 24px;
  border: 1px solid var(--border-purple);
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 40px var(--accent-purple-glow);
}
.modal-large { max-width: 820px; width: 95%; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.8rem; margin-top: 1.5rem; }

/* Tabla de Reportes y Logs */
.reports-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.88rem; }
.reports-table th, .reports-table td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border-color); }
.reports-table th { color: var(--text-muted); text-transform: uppercase; font-size: 0.75rem; }

/* WebRTC Call Overlay */
.call-card {
  background: #000;
  width: 92%;
  max-width: 820px;
  height: 520px;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid var(--border-purple);
  box-shadow: 0 0 50px var(--accent-purple-glow);
}
.call-status-bar { background: var(--bg-paper); padding: 0.6rem; text-align: center; font-size: 0.88rem; color: var(--accent-amber); font-weight: bold; border-bottom: 1px solid var(--border-color); }
.video-grid { flex: 1; position: relative; background: #08080c; display: flex; justify-content: center; align-items: center; }
.video-remote { width: 100%; height: 100%; object-fit: cover; }
.video-local { width: 170px; height: 125px; position: absolute; bottom: 20px; right: 20px; border-radius: 14px; border: 2px solid var(--accent-pink); object-fit: cover; background: #111; }
.call-actions { padding: 1.2rem; background: var(--bg-paper); display: flex; justify-content: center; gap: 1.5rem; }
.call-action-btn { background: var(--bg-hover); border: none; color: white; padding: 1rem; border-radius: 50%; cursor: pointer; display: flex; }
.call-action-btn.end-call { background: var(--danger); box-shadow: 0 0 15px rgba(244, 63, 94, 0.4); }

/* Switch Toggle */
.toggle-setting-row { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.switch { position: relative; display: inline-block; width: 52px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bg-hover); transition: .3s; border-radius: 34px; border: 1px solid var(--border-color); }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent-purple); }
input:checked + .slider:before { transform: translateX(24px); }

/* Pestañas Host */
.host-tabs { display: flex; gap: 0.5rem; border-bottom: 1px solid var(--border-color); margin-bottom: 1.5rem; overflow-x: auto; }
.host-tab-link, .settings-tab-link { background: transparent; border: none; color: var(--text-muted); padding: 0.8rem 1rem; cursor: pointer; border-bottom: 2px solid transparent; font-weight: 600; white-space: nowrap; }
.host-tab-link.active, .settings-tab-link.active { color: var(--accent-purple); border-bottom-color: var(--accent-purple); }
.host-section, .settings-section { display: none; }
.host-section.active, .settings-section.active { display: block; }

/* RESPONSIVO */
.mobile-only { display: none !important; }

@media (max-width: 768px) {
  .mobile-only { display: flex !important; }
  .sidebar-left { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 20; }
  .sidebar-right { display: none !important; }
  .msg-wrapper { max-width: 88%; }
  
  body.chat-view-active .sidebar-left { transform: translateX(-100%); }
}