/* ═══════════════════════════════════════════════════════════════════
   MAPITA — Dashboard de Relaciones (panel lateral)
   Solo visible para admins. Accesible desde el popup de cualquier negocio.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Panel lateral ───────────────────────────────────────────────── */
#rd-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 340px;
  height: 100dvh;
  background: #fff;
  border-left: 1px solid #dde3f0;
  box-shadow: -6px 0 28px rgba(0,0,0,0.13);
  z-index: 2100;
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#rd-panel.rd-open {
  right: 0;
}

/* ── Header ──────────────────────────────────────────────────────── */
.rd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1B3B6F 0%, #2E5FA3 100%);
  color: white;
  flex-shrink: 0;
}
#rd-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}
.rd-close-btn {
  background: rgba(255,255,255,0.18);
  border: none;
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.rd-close-btn:hover { background: rgba(255,255,255,0.30); }

/* ── Sección de lista ────────────────────────────────────────────── */
#rd-view-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rd-add-btn {
  width: 100%;
  padding: 10px;
  background: #f0f4ff;
  border: 2px dashed #1B3B6F;
  border-radius: 10px;
  color: #1B3B6F;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.rd-add-btn:hover { background: #dce8ff; }

#rd-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rd-loading, .rd-empty {
  padding: 24px 0;
  text-align: center;
  color: #888;
  font-size: 13px;
  line-height: 1.6;
}
.rd-error { color: #c0202d; }

/* ── Fila de relación ────────────────────────────────────────────── */
.rd-rel-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: #f8faff;
  border: 1px solid #e4eaf8;
  border-radius: 10px;
  transition: opacity 0.25s;
}
.rd-rel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.rd-rel-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rd-rel-type {
  font-size: 12px;
  font-weight: 700;
  color: #1B3B6F;
}
.rd-rel-arrow {
  font-size: 12px;
  color: #4a5568;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rd-rel-desc {
  font-size: 11px;
  color: #718096;
  font-style: italic;
}
.rd-del-btn {
  background: none;
  border: none;
  color: #c0202d;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.rd-del-btn:hover { opacity: 1; }

/* ── Hint de selección ───────────────────────────────────────────── */
#rd-select-hint {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.rd-hint-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: #f0f4ff;
  border: 2px solid #1B3B6F;
  border-radius: 16px;
  padding: 28px 24px;
}
.rd-hint-icon {
  font-size: 36px;
  animation: rdPulse 1.6s ease-in-out infinite;
}
@keyframes rdPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15) translateY(-3px); }
}
.rd-hint-text {
  font-size: 15px;
  font-weight: 700;
  color: #1B3B6F;
  line-height: 1.5;
}

/* ── Formulario de nueva relación ────────────────────────────────── */
#rd-view-form {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rd-form-section {}
.rd-form-label {
  font-size: 11px;
  font-weight: 700;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.rd-target-chip {
  background: #f0f4ff;
  border: 1px solid #c3d1f8;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #1B3B6F;
  min-height: 36px;
  display: flex;
  align-items: center;
}
.rd-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rd-type-btn {
  padding: 10px 8px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  font-size: 12px;
  font-weight: 600;
  color: #2d3748;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.rd-type-btn:hover {
  border-color: var(--type-color, #1B3B6F);
  background: color-mix(in srgb, var(--type-color, #1B3B6F) 8%, white);
}
.rd-type-btn.active {
  border-color: var(--type-color, #1B3B6F);
  background: var(--type-color, #1B3B6F);
  color: white;
}
.rd-desc-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d0d7e8;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #2d3748;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.rd-desc-input:focus { border-color: #1B3B6F; box-shadow: 0 0 0 3px rgba(27,59,111,0.12); }
.rd-form-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}
.rd-save-btn {
  width: 100%;
  padding: 11px;
  background: #1B3B6F;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.rd-save-btn:hover:not(:disabled) { background: #2E5FA3; }
.rd-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.rd-cancel-btn {
  width: 100%;
  padding: 9px;
  background: white;
  color: #4a5568;
  border: 1px solid #d0d7e8;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.rd-cancel-btn:hover { background: #f7fafc; }

/* ── Botón "🔗 Vincular" en el popup (solo admin) ────────────────── */
.rd-popup-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: #f0f4ff;
  border: 1px solid #c3d1f8;
  border-radius: 20px;
  color: #1B3B6F;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.rd-popup-btn:hover { background: #dce8ff; }

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #rd-panel {
    width: 100vw;
    right: -100vw;
  }
  .rd-type-grid { grid-template-columns: 1fr 1fr; }
}
