:root {
  --bg-dark: #080d1a;
  --bg-card: #111a2e;
  --bg-surface: #1b2640;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #10b981;
  --border: #233354;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Modal Overlay & Card */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 13, 26, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
}

.auth-card {
  max-width: 520px;
}

.auth-header {
  margin-bottom: 20px;
}

.badge {
  display: inline-block;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.auth-header h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Tabs de Autenticación */
.auth-tabs {
  display: flex;
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
  gap: 4px;
}

.auth-tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.auth-form-content.hidden {
  display: none;
}

/* Formularios */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.dept-tag-input-wrapper {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.btn-add-dept {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.dept-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.dept-tag {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dept-tag .remove-tag {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.field-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.color-picker {
  display: flex;
  gap: 12px;
}

.color-swatch {
  cursor: pointer;
}

.color-swatch input {
  display: none;
}

.color-swatch span {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--c);
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}

.color-swatch input:checked + span {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 10px var(--c);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Header & HUD */
.game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.game-container.hidden {
  display: none;
}

.game-header {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.office-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.controls-hint {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.controls-hint strong {
  color: #fff;
}

/* WALKIE-TALKIE PUSH-TO-TALK BUTTON (ESTILO RADIO TAXI) */
.ptt-container {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 20;
}

.btn-ptt {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1e293b;
  border: 2px solid #3b82f6;
  color: #fff;
  padding: 14px 22px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(59, 130, 246, 0.3);
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

.btn-ptt:hover {
  background: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.4);
}

.btn-ptt.transmitting,
.btn-ptt:active {
  background: #10b981 !important;
  border-color: #059669 !important;
  transform: scale(0.96) !important;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.8) !important;
}

.ptt-icon {
  font-size: 18px;
}

.transmitting-indicator {
  position: absolute;
  top: 24px;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid #10b981;
  color: #34d399;
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(8px);
  animation: pulse 1s infinite;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.transmitting-indicator.hidden {
  display: none !important;
}

/* LLAMADA PRIVADA 1 A 1 */
.incoming-call-card {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 26, 46, 0.95);
  border: 2px solid #10b981;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(16, 185, 129, 0.4);
  border-radius: 14px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 60;
  backdrop-filter: blur(10px);
  animation: pulse 1s infinite;
}

.incoming-call-card.hidden {
  display: none !important;
}

.incoming-call-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.incoming-call-info strong {
  font-size: 15px;
  color: #fff;
}

.incoming-call-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.call-pulse-dot {
  width: 14px;
  height: 14px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 14px #10b981;
}

.incoming-call-actions {
  display: flex;
  gap: 8px;
}

.btn-call-accept {
  background: #10b981;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.1s;
}

.btn-call-accept:hover {
  background: #059669;
}

.btn-call-reject {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.btn-call-reject:hover {
  background: #ef4444;
  color: #fff;
}

/* BARRA DE LLAMADA ACTIVA */
.active-call-bar {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  border-radius: 30px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 60;
  backdrop-filter: blur(8px);
}

.active-call-bar.hidden {
  display: none !important;
}

.active-call-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #34d399;
}

.btn-call-hangup {
  background: #ef4444;
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* BOTÓN TOGGLE SIDEBAR EN MÓVILES */
.btn-toggle-sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-toggle-sidebar:hover {
  background: var(--primary);
  border-color: var(--primary);
}

/* JOYSTICK TÁCTIL VIRTUAL PARA MÓVILES */
.mobile-joystick-wrapper {
  position: absolute;
  bottom: 24px;
  left: 24px;
  z-index: 25;
  touch-action: none;
  user-select: none;
}

.joystick-base {
  width: 110px;
  height: 110px;
  background: rgba(17, 26, 46, 0.7);
  border: 2px solid rgba(59, 130, 246, 0.5);
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.joystick-stick {
  width: 44px;
  height: 44px;
  background: var(--primary);
  border: 2px solid #fff;
  border-radius: 50%;
  position: absolute;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.8);
  pointer-events: none;
  transform: translate(0, 0);
  transition: transform 0.05s ease-out;
}

/* BOTÓN TÁCTIL DE ACCIÓN [E] */
.mobile-action-btn {
  position: absolute;
  bottom: 95px;
  right: 24px;
  z-index: 25;
  background: #3b82f6;
  border: 2px solid #fff;
  color: #fff;
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.6);
  animation: pulse 1.2s infinite;
}

.mobile-action-btn.hidden {
  display: none !important;
}

/* RESPONSIVE DESIGN PARA MÓVILES (PANTALLAS <= 768px) */
@media (max-width: 768px) {
  .game-header {
    padding: 0 12px;
    height: 56px;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-sub,
  .controls-hint,
  .hide-mobile {
    display: none !important;
  }

  .header-actions {
    gap: 8px;
  }

  .online-pill {
    padding: 4px 8px;
    font-size: 11px;
  }

  .btn-logout {
    padding: 4px 8px;
    font-size: 11px;
  }

  /* El juego 3D ocupa el 100% de la pantalla */
  .game-main {
    position: relative;
  }

  .canvas-wrapper {
    width: 100vw;
    height: calc(100vh - 56px);
  }

  /* La barra lateral se convierte en un Drawer deslizable */
  .sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 85%;
    max-width: 340px;
    z-index: 50;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.7);
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Ajustar botón Walkie-Talkie para móvil */
  .ptt-container {
    bottom: 24px;
    right: 20px;
  }

  .btn-ptt {
    padding: 12px 16px;
    font-size: 12px;
  }

  .interaction-prompt {
    bottom: 150px;
    font-size: 12px;
    padding: 8px 12px;
  }

  .auth-card {
    padding: 20px;
    max-width: 95%;
  }

  .modal-card {
    padding: 20px;
  }

  .npc-avatar-wrapper {
    width: 56px;
    height: 56px;
  }

  .npc-avatar-img {
    width: 56px;
    height: 56px;
  }

  .npc-speech-bubble {
    font-size: 14px;
    padding: 14px;
  }
}

/* Área 3D */
.game-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.canvas-wrapper {
  flex: 1;
  background: #060911;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#canvas3dContainer canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.interaction-prompt {
  position: absolute;
  bottom: 24px;
  background: rgba(17, 26, 46, 0.95);
  border: 1px solid var(--primary);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
  animation: pulse 1.5s infinite;
}

.interaction-prompt.hidden {
  display: none !important;
}

.interaction-prompt kbd {
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.meeting-alert {
  position: absolute;
  top: 24px;
  background: rgba(236, 72, 153, 0.15);
  border: 1px solid #ec4899;
  color: #f472b6;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  backdrop-filter: blur(6px);
}

.meeting-alert.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}

/* Sidebar */
.sidebar {
  width: 360px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 14px 8px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  background: rgba(59, 130, 246, 0.06);
}

.tab-content {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

/* Chat */
.proximity-banner {
  background: rgba(16, 185, 129, 0.1);
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent);
}

.chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  background: var(--bg-surface);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  border-left: 3px solid transparent;
}

.chat-msg.near {
  border-left-color: var(--accent);
  background: rgba(16, 185, 129, 0.08);
}

.chat-msg.meeting {
  border-left-color: #ec4899;
  background: rgba(236, 72, 153, 0.08);
}

.chat-msg-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.chat-msg-header strong {
  color: #fff;
}

.chat-input-bar {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-input-bar input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.chat-input-bar button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

/* Tasks & Onboarding */
.checklist-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.progress-wrap {
  margin-bottom: 12px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.progress-info strong {
  color: var(--accent);
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--bg-surface);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.3s ease;
}

.checklist-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.task-list {
  list-style: none;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.task-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.2s;
}

.task-item.completed {
  border: 1px solid var(--accent);
  background: rgba(16, 185, 129, 0.08);
}

.task-item.completed strong {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-item p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Admin Form */
.admin-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.admin-header h3 {
  font-size: 14px;
  margin-bottom: 4px;
}

.admin-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.admin-form {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* MODAL DE DIÁLOGO NPC CON CARA REAL */
.npc-dialog-card {
  max-width: 540px;
}

.npc-profile-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.npc-avatar-wrapper {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.npc-avatar-img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.online-dot {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 2px solid var(--bg-card);
  border-radius: 50%;
}

.npc-details h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 4px 0 2px 0;
}

.npc-role-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.npc-speech-bubble {
  background: rgba(8, 13, 26, 0.7);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 18px;
  border-radius: 12px;
  margin-bottom: 22px;
  font-size: 15px;
  line-height: 1.6;
  color: #e2e8f0;
}
